Manages tokens and secrets, and proxies network requests. Works with Petfinder API v2.
To use this proxy to support a front-end app, you should run your own copy of it - You can do this for free on Heroku.
- Create a Heroku account (or log in if you have one already).
- Click the Deploy button above.
- Fill in the App Name - the proxy will be deployed to http://your-app-name-here.herokuapp.com
- Fill in your Petfinder
clientSecret
. - Click Deploy App.
Note: This proxy only supports GET requests.
Send your request to the /petfinder
endpoint (e.g. http://your-app-name-here.herokuapp.com/petfinder) with the following query params:
clientId
(required): your API key (provided by Petfinder)reqUrl
(required): the Petfinder API endpoint URL you want to request data fromparams
(optional): query params for your Petfinder API call (an object, formatted as a JSON string) - e.g.{"page": 2}
proxyHeaders
(optional): any headers you need to send along with your Petfinder API call (an object, formatted as a JSON string) - e.g.{"My-Custom-Header": "headerValueHere"}
fetch(
'http://your-app-name-here.herokuapp.com/petfinder?reqUrl=https://api.petfinder.com/v2/animals¶ms={"page": 2}&clientId=yourapikeyhere'
)
.then(res => res.json())
.then(petData => console.log(petData));
or, with axios:
axios({
method: 'GET',
url: 'http://your-app-name-here.herokuapp.com/petfinder',
params: {
reqUrl: 'https://api.petfinder.com/v2/animals',
params: {
page: 2,
},
clientId: 'yourapikeyhere',
},
}).then(res => console.log(res.data));
- Install Docker
yarn
to install JavaScript dependencies- Create a file named
.env
in the project's root directory with the following environment variables:
CLIENT_SECRET=yourClientSecretHere
REDIS_URL=redis:6379
docker-compose up
from the project's root directory to start the app (listens on port 4000 by default)