metero-api
v2.0.4
Published
Metero api client.
Downloads
9
Readme
metero-api
Metero api client.
Install
npm install --save metero-api
Documentation
This just a client. API Documentation
ApiClient
You can create new api client instance with
const client = new ApiClient({
format: 'json',
accessToken: '[Access token]'
})
or
const client = new ApiClient()
format - 'json'|'jsonld' - 'json' matches 'application/json' mime type. 'jsonld' matches 'application/ld+json' mime type. For more details see the api docs.
accessToken - string|null - use to authorize to api.
.setFormat
client.setFormat('json')
Sets or changes format.
format - 'json'|'jsonld' - 'json' matches 'application/json' mime type. 'jsonld' matches 'application/ld+json' mime type. For more details see the api docs.
.setAccessToken
client.setAccessToken('[Access token]')
Sets or changes access token.
accessToken - string|null - use to authorize to api.
.getUsers
client.getUsers(queryParameters).then(users => {
// do something
}).catch(error => {
// do something
})
Fetches multiple users.
queryParameters - object - url parameters. In docs marked with '(query)'. Optional.
Note: after second version all method except deletePost, setFormat and setAccessToken supports typescript generics
.getUser
client.getUser(username).then(user => {
// do something
}).catch(error => {
// do something
})
Fetches a single user.
username - string - Username of user.
.updateUser
client.updateUser(username, body).then(user => {
// do something
}).catch(error => {
// do something
})
Partially updates the user.
username - string - Username of user. body - object - Fields to be updated.
.getPosts
client.getPosts(queryParameters).then(posts => {
// do something
}).catch(error => {
// do something
})
Fetches multiple posts.
queryParameters - object - Url parameters. In docs marked with '(query)'. Optional.
.createPost
client.createPost(data).then(post => {
// do something
}).catch(error => {
// do something
})
Creates new post.
body - object - Body of new post.
.getPost
client.getPost(id).then(post => {
// do something
}).catch(error => {
// do something
})
Fetches a single post.
id - number - Id of post.
.replacePost
client.replacePost(id, body).then(post => {
// do something
}).catch(error => {
// do something
})
Replaces old post values with new values.
id - number - Id of post.
body - Fields to be replaced.
.deletePost
client.deletePost(id).then(() => {
// do something
}).catch(error => {
// do something
})
Deletes post.
id - number - Id of post.
.updatePost
client.updatePost(id, body).then(post => {
// do something
}).catch(error => {
// do something
})
Partially updates the post.
id - number - Username of user.
body - object - Fields to be updated.
License
MIT © ArtemGolovko