swarmapp-api
Advanced tools
Comparing version 1.0.2 to 1.0.4
35
main.js
@@ -16,2 +16,16 @@ const _ = require('lodash'); | ||
} | ||
async login(username, password, client_id, client_secret) { | ||
const params = { | ||
client_id: client_id, | ||
client_secret: client_secret, | ||
username: username, | ||
password: password, | ||
grant_type: 'password', | ||
}; | ||
const response = await axios.post(this.basePath + '/oauth2/access_token', null, { params }); | ||
this.config.access_token = response.data.access_token; | ||
return response.data.access_token; | ||
} | ||
@@ -34,3 +48,3 @@ // Get Commands | ||
} | ||
getLastSeen(options = {}) { | ||
@@ -73,2 +87,3 @@ | ||
delete this.config.afterTimeStamp; | ||
_.defaults(this.config, { | ||
@@ -84,2 +99,20 @@ 'USER_ID': 'self', | ||
async getCheckinsByUserId(userId) { | ||
_.defaults(this.config, { | ||
'user_id': userId | ||
}); | ||
delete this.config.afterTimeStamp; | ||
_.defaults(this.config, { | ||
'user_id': userId, | ||
'limit': 100, | ||
'afterTimestamp': options.afterTimestamp, | ||
}); | ||
const response = await axios.get(this.basePath + '/users/' + options.user_id + '/checkins', { 'params': this.config }); | ||
return response.data; | ||
} | ||
// returns user timeline after timestamp | ||
@@ -86,0 +119,0 @@ async getRecent(options = {}) { |
{ | ||
"name": "swarmapp-api", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "A javascript wrapper for swarmapp (foursquare) API", | ||
"main": "main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Dummy Test\"" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
# Swarmapp-api | ||
A JavaScript wrapper for SwarmApp (foursquare) API | ||
The `swarmapp-api` repository is a Node.js library that provides a programmatic interface to the SwarmApp API (Foursquare), which is the official API for the SwarmApp social networking app. | ||
## Installation | ||
> SwarmApp allows users to check-in to places and share their experiences with friends. The API provides various endpoints for creating and retrieving check-ins, as well as for authenticating users and managing their profiles. | ||
Only offered through NPM | ||
`$ npm install --save swarmapp-api` | ||
The `swarmapp-api` library provides a set of functions that make it easy to interact with the SwarmApp API programmatically. These functions abstract away the details of making HTTP requests to the API and handling the responses, so that you can focus on building your application logic. | ||
## Usage | ||
The library includes modules for authentication, check-ins, places, users, and more. Each module provides a set of functions that correspond to the endpoints of the SwarmApp API, making it easy to perform the most common operations. | ||
To be revised | ||
The `swarmapp-api` library is designed to be used by developers who want to build integrations with the SwarmApp platform. By using the library, you can build applications that leverage the data and functionality of the SwarmApp social network, such as location-based recommendations, social analytics, and more. | ||
### Initialize | ||
```javascript | ||
const swarmappapi = require('swarmapp-api'); | ||
const swarm = new swarmappapi({ api_key: <your-api-key> }); | ||
``` | ||
### Call a function | ||
## Getting Started | ||
```javascript | ||
function exampleGetFriends() { | ||
try { | ||
return api.getFriends(); | ||
} | ||
catch (error) { | ||
console.error('error: ' + error); | ||
} | ||
} | ||
``` | ||
To get started with the SwarmApp API, follow these steps: | ||
1. `$ npm i swarmapp-api` | ||
## Example Usage | ||
Let's say you want to retrieve the list of check-ins for a particular user on SwarmApp using the API. | ||
1. First, you'll need to authenticate the user and get an access token. You can do this by calling the login function from the auth module: | ||
```javascript | ||
const swarmappapi = require('swarmapp-api'); | ||
const swarm = new swarmappapi({ api_key: API_KEY }); | ||
const email = 'user@example.com'; | ||
const password = 'password123'; | ||
const client_id = 'xxxxxxxxx'; | ||
const client_secret = 'xxxxxxxxxx'; | ||
const accessToken = await swarm.login(email, password, client_id, client_secret); | ||
``` | ||
The `login` function returns an object that includes the access token, which you'll use in the next step. | ||
2. Next, you can use the access token to retrieve the list of check-ins for the user. You can do this by calling the `getCheckinsByUserId` function from the `checkins` module: | ||
```javascript | ||
const swarmappapi = require('swarmapp-api'); | ||
const swarm = new swarmappapi({ api_key: API_KEY }); | ||
const userId = '123'; | ||
const checkins = await swarm.getCheckinsByUserId(userId, accessToken); | ||
console.log(checkins); | ||
``` | ||
The `getCheckinsByUserId` function returns an array of check-ins for the specified user. | ||
That's it! You've now retrieved the list of check-ins for the user on SwarmApp using the API. | ||
## Dependencies | ||
@@ -44,6 +70,14 @@ | ||
## Contributions | ||
## Contributing | ||
1. Fork | ||
2. Edit | ||
3. Push | ||
We welcome contributions from the community! To contribute to the SwarmApp API, follow these steps: | ||
1. Fork the repository | ||
2. Create a new branch for your changes: git checkout -b my-feature-branch | ||
3. Make your changes and commit them: git commit -am "Add new feature" | ||
4. Push your changes to your fork: git push origin my-feature-branch | ||
5. Create a pull request against the main branch of the `6degrees/swarmapp-api` repository | ||
## License | ||
The SwarmApp API is licensed under the MIT License. See the LICENSE file for details. |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
13020
7
250
0
83
1