Get Authenticated with Traxain's API

This is a brief introduction on the most common methods in our API, for a more complete explanation, visit https://api.traxain.xyz/docs . In our docs you'll alsp be able to test all methods described here.



Authentication

Creating a user

Before you start using traxain, you need to have an account. You can do it using our graphic interface in https://traxain.xyz, using the /user/create/ method in our interactive documentation, or by calling the following endpoint:


https://api.traxain.xyz/user/create/


With the following body:


{
  "email": "string",
  "srp_account": "string",
  "srp_checkout_id": "string",
  "srp_customer": "string",
  "is_active": true,
  "hashed_password": "string",
  "username": "string",
  "address": "string" }


Right now, you just need to fill the email, hashed password, username, and Address. ( if its the first time you create this user the password is hashed afterwards) Make sure that the mail is not registered yet and that the password is at least 8 characters long.


You can skip for now the other fields and pass the request with the default values. However, if you already have a Stripe account, a stripe user or a checkout id, you can assign them on creation.




Getting a token

Great, now you have an account, but in order to use our platform you'll need to authenticate yourself. We use OAuth2, which means that you'll need to pass a token on your requests.


The first time you create a user you'll be returned a token. But you can retrieve your token whenever you want, you need to use the /user/token method in our interactive documentation, or calling the following endpoint.


https://api.traxain.xyz/user/token


Specify the Content-Type as application/x-www-form-urlencoded in the headers, and pass the body as a JSON in the following way:


'grant_type=&username='<UserName>'&password='<Password>'&scope=&client_id=&client_secret='


Leave the other fields empty for now.




Using your token


If you want to use our interactive documentation you should log in directly with swagger. To do that, look for the Authorize button in the top right if your screen and fill the form with your mail and password.



If you need to use it programatically, or test it with another tool like Postman, make sure you that your headers specify the Content-Type as application/json, and the Authorization as Bearer + " " + <your token>. Make sure you leave a space between Bearer and your token, as it is a common mistake.


What's next

Depending on whether you are a shipper, a carrier, an intermediary, or an employee, you'll have access to different methods. You can check them in our interactive documentation and feel free to mail us at ignacio@traxain.com if you have any question or suggestion.