Authentication
To use the PathStack API, you must pass a JWT access token in the header of each request. This is for security to ensure no one else can access your data.
Generating an access token
To get an access token, you need to make a call to the /token
endpoint and pass your username and password.
Access tokens expire 60 minutes after they are generated. Once an access token has expired you will no longer be able
to use it and any API calls you try to make will return a 401: JWT has expired error response with a message that
the token has expired. You will then either have to generate a new token with the /token
endpoint, or you can use
the Refresh Token from the original /token
call to get a new Access Token.
This will return a response that looks something like this:
Now that you have an Access Token, you can begin making requests to the PathStack API.
Using a refresh token
To get a new token, you can either authenticate again with your username and password, or you call the /refresh
endpoint.
The latter option is often preferable since you will not need to store your username and password for later use.
Using the sub
and the refresh_token
, you can call the /refresh
endpoint to get new access and refresh token.