Getting started
Last updated
Was this helpful?
Last updated
Was this helpful?
Warpgate API uses API keys to authenticate requests. You can generate your API keys in your . Whenever you make a GraphQL query to Warpgate, we look for Authorization: Bearer ${API_TOKEN}
in the header.
Do not embed your API keys in your Github repository, or in client-side code, etc. it's best to put your Warpgate API keys as an environment variable.
Your API keys grant you access to all GraphQL queries and mutations of your data in Warpgate. So make make sure you keep your API keys secure.
To see the full capabilities of Warpgate API, you can head over to its .
There you will be able to view the different types of objects you can query or mutate.
Warpgate uses standard GraphQL and has no SDK that is required to be installed in your codebase. To get started right away, here is a utility function that you can copy and paste to your codebase.
./util/warpgateQuery.js
NOTE: include your WARPGATE_API_KEY
in your environment variables.
If you're using Next.js, here's an example on how you would use it in your /api/register.js
file.
If you're building a React.js application, you most probably want to display the errors on the client side easily.
In Warpgate, whenever a mutation has validation errors, it will return an error message that lets you identify the fields that need to be corrected.
Let's take a look at this example response for an invalid user login:
E.g. errors.username
, errors.password
, etc.
The benefit of using GraphQL is nested queries. This lets developers have the freedom to define which fields they exactly need without doing two or more HTTP requests to the server.
Example, if you're fetching user data along with other associated data such as their user profile and wallet balances:
Will return a payload response like this:
In the warpgateQuery.js
, it will automatically map the error array values into an object. This makes it easy to easily check which fields need to be highlighted in the front-end.
Not only is this bandwidth efficient, but it also enables you to avoid having to do .