Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
ackee-api-agent
Advanced tools
> Renamed (and reimplemented) to [@ackee/antonio](https://github.com/AckeeCZ/antonio)
Renamed (and reimplemented) to @ackee/antonio
import ApiAgent from 'ackee-api-agent';
const api = new ApiAgent('http://my-custom-api.ack.ee/api/v2');
const driversFilter = {
filter: {
offset: 3,
limit: 10,
},
}
const params = {
resolveWithFullResponse: true,
};
// get data
api.get('/metadata')
.then(metadata => console.log(metadata));
// set data
api.post('/drivers', driversFilter, params);
.then(drivers => console.log(drivers))
api.post('/groups', { name: 'new group', description: 'New testing group' })
.catch(err => console.log('Group was not created'));
ApiAgent
Class that has following instance methods.
constructor(basePath: string)
request(path: string, params: IParams): Promise<IResponse|IResponseBody>
get(path: string, params: IParams): Promise<IResponse|IResponseBody>
post(path: string, data: IData, options: IOptions): Promise<IResponse|IResponseBody>
put(path: string, data: IData, options: IOptions): Promise<IResponse|IResponseBody>
patch(path: string, data: IData, options: IOptions): Promise<IResponse|IResponseBody>
delete(path: string, options: IOptions): Promise<IResponse|IResponseBody>
IData: Object
Key-value object containing any data you want to send to server in request body.
IOptions: Object
Object optionally containing following properties.
uriParams: Object
Key-value object containing request uri params. Params that are found in url are replaced,
rest is appended as a query parameters.const config = {
api: {
base: "http://api-domain",
user: "/users/:user",
},
};
const api = new ApiAgent(config.api.base);
const uriParams = {
user: 13,
include: "address",
};
api.get(config.api.user, { uriParams });
// requested url is 'http://api-domain/users/13?include=address
qs: Object
Ke-value object containing request query string params. Add query params to urlconst config = {
api: {
base: "http://api-domain",
users: "/users",
},
};
const api = new ApiAgent(config.api.base);
const qs = {
page: 3,
offset: 20,
};
api.get(config.api.users, { qs });
// requested url is 'http://api-domain/users?page=3&offset=20
json: boolean
Determine when optionally provided IData
is in JSON format and should be serialized to string.
Alos set request header ContentType=application/json
. Default is true
.
headers: Object
Request HTTP headers.
resolveWithFullResponse: boolean
Determine if request should resolve with full response or just a response body. Default is false
.
blob: boolean
Determine if response should be treated as a binary data. Default is false
.
const api = new ApiAgent(config.api.base);
api.get("/download/pdf", { blob: true }).then((pdf) => {
// pdf === Blob(205990) {size: 205990, type: "application/octet-stream"}
const uri = URL.createObjectURL(pdf);
// uri === 'blob:http://my-app-url/fb0b4600-8377-4357-a240-8346e94a0384'
});
IParams: Object
All the IOptions
contains and following properties.
method: string
Http method name.
body: IData
Optional.
IResponse|IResponseBody
Type of response is determined by resolveWithFullResponse
request property. It's either
just response data in JSON format, or full response containing following properties.
const api = new ApiAgent(config.api.base);
api.get("/users").then((users) => {
console.log(JSON.stringify(users));
// [{"id":1,"name":"Me"},{"id":2,"name":"You"},{"id":3,"name":"He"}]
});
api.get("/users", { resolveWithFullResponse: true }).then((response) => {
console.log(JSON.stringify(response.body));
// [{"id":1,"name":"Me"},{"id":2,"name":"You"},{"id":3,"name":"He"}]
response.status === 200; // true
result.headers.get("x-total-count") === "3"; // true
});
body: IResponseBody
status: number
statusText: string
url: string
headers: Object
Key-value object containing response headers.
ok: boolean
FAQs
> Renamed (and reimplemented) to [@ackee/antonio](https://github.com/AckeeCZ/antonio)
The npm package ackee-api-agent receives a total of 5 weekly downloads. As such, ackee-api-agent popularity was classified as not popular.
We found that ackee-api-agent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.