ppl-api-client-js
A simple Javascript client for people.io API.
Subscribe to our developer program and obtain your credentials on https://developer.people.io/
Install:
npm install @people.io/ppl-api-client-js --save
Obtaining a user token:
In order to call the API you will need to act as an authenticated user.
A valid implicit oAuth url can be obtained by:
const client = require('@people.io/ppl-api-client-js');
const scope = ['brands', 'sports'];
const destination = "https://myserver.io/tokenCapture";
const state = 'calculate-your-state-hash'
const url = client.getUserAuthURL(scope, destination, { state });
console.log('User authentication page: ', url);
Configuration:
You can configure the library in two ways:
Programmatically:
Using the configure()
method
const client = require('@people.io/ppl-api-client-js');
const myConfiguration = {
apiKey: 'my-api-key',
clientId: 'my-client-id',
userToken: 'my-user\'s-user-token'
};
const updateConfig = client.configure(testConf);
console.log('ppl-api-client config: ', { updateConfig });
or you can pass the details to each call:
const client = require('@people.io/ppl-api-client-js');
getUserAudiences(null, { token, apiKey, clientId }).then(console.log).catch(console.error);
Environment Variables:
PPL_API_KEY="my-api-key"
PPL_CLIENT_ID="my-client-id"
Functions list:
All the functions can be used both in an async/await/
or promise
fashion
getAudiences(name, { limit, page, token, apiKey, clientId })
getAudienceGroups(name, { limit, page, token, apiKey, clientId })
getUserAudiences(audienceGroupId, { token, apiKey, clientId })
getUserIdToken({ token, apiKey, clientId })
getUserAuthURL(scope, desination, { clientId, state })
The token
, apiKey
, and clientId
parameters become optional when previously stated or configured.
See the above configuration section for more informations.
Testing:
npm test
Development
npm start