trucker-api (1.0.0)

Download OpenAPI specification:Download

Import

To import this api into your favorite api tester click "Download" and import downloaded file using import functions in your tool.

Change base url of server (usually it is stored as a variable that you can modify) when importing to reflect proper server url.

Generic responses

Generic response may be returned to any request that is missing some required data. To not repeat the same piece of documentation everywhere generic responses will be omitted from examples and you should assume that when request is mailformed you may recieve generic response.

One or more required fields are missing

HTTP 400 Bad Request

{
  "{field}": ["This field is required."]
}

Required fields are marked with required beside field name

Throttling

Server has a configured throttling mechanism, throttling is done on per-user basis and could be split into given categories

  • Requests from authenticated user: 100/min
  • Endpoints that require frequent access 100/min
  • Requests from unauthenticated user: 10/min
  • Any request that contain file upload: 5/min

Full list of endpoints with their limits is available here

When request is throttled the following response will be returned

HTTP 429 Too Many Requests

{
  "detail": "Request was throttled. Expected available in {num} seconds."
}

Number of seconds after which request can be made is also available in Retry-After header

Pagination

For some endpoints that return a lot of results (such as friend listing or account search) there is an implemented pagination mechanism that is is used to split long results into multiple pages.

Paginated results have this form:

{
    "count": ,
    "num_pages": 3,
    "next": http://example.com/?page=3
    "previous": http://example.com/?page=1
    "results": [
    ]
}

Where

  • count - Total amount of results
  • num_pages - Total amount of pages
  • next - Link to next page with results
  • previous - Link to previous page with results

Authentication

bearerAuth

Authorization using JWT

Generic responses

Access token is invalid or expired

HTTP 401 Unauthorized

{
  "detail": "Given token not valid for any token type",
  "code": "token_not_valid"
  "message" {
    "token_class": "AccessToken"
    "token_type": "access"
    "message": "Token is invalid or expired"
  }
}

Access token is not provided

HTTP 401 Unauthorized

{
  "detail": "Authentication credentials were not provided"
}
Security Scheme Type HTTP
HTTP Authorization Scheme bearer
Bearer format "JWT"

Authorization/Login

Register new user

Server converts all images in RGBA colorspace into RGB. It is recommended that this conversion is done on client side to decrease load on server and speed up request processing.

Image sizes are limited to 5MB

Request Body schema: application/json
phone
required
string <= 64 characters
password
required
string <password> <= 128 characters
first_name
required
string
last_name
required
string
email
required
string <email> <= 254 characters

Responses

Request samples

Content type
application/json
{
  • "phone": "+123456789012",
  • "password": "pa$$word",
  • "first_name": "first",
  • "last_name": "last",
  • "email": "user@example.com"
}

Response samples

Content type
application/json
{
  • "access": "string",
  • "refresh": "string"
}

Login

Request Body schema: application/json
phone
required
string <= 64 characters
password
required
string <password> <= 128 characters

Responses

Request samples

Content type
application/json
{
  • "phone": "+123456789012",
  • "password": "pa$$word"
}

Response samples

Content type
application/json
{
  • "access": "string",
  • "refresh": "string"
}

Refresh token

Request Body schema: application/json
refresh
required
string

Responses

Request samples

Content type
application/json
{
  • "refresh": "string"
}

Response samples

Content type
application/json
{
  • "access": "string",
  • "refresh": "string"
}

Login with facebook

Given facebook access token log user in or register new user

Access token should have following permissions:

  • public_profile
  • email
  • user_birthday
Request Body schema: application/json
access
required
string

Access token

Responses

Request samples

Content type
application/json
{
  • "access": "string"
}

Response samples

Content type
application/json
{
  • "access": "string",
  • "refresh": "string"
}

Login with google

Given google access token log user in or register new user

Access token should have following scopes:

Request Body schema: application/json
access
required
string

Access token

Responses

Request samples

Content type
application/json
{
  • "access": "string"
}

Response samples

Content type
application/json
{
  • "access": "string",
  • "refresh": "string"
}

Password reset

Password reset

Send sms with password reset code to given number.

This endpoint always returns success even if phone number is invalid.

Reset code is active for 5 minutes. Code resend for the same phone number is possible only after the previous code is expired.

Request Body schema: application/json
phone
required
string

Phone number

Responses

Request samples

Content type
application/json
{
  • "phone": "+123456789012"
}

Confirm password reset

Change password given reset code and phone number

Request Body schema: application/json
phone
required
string

Phone number

code
required
string 8 characters

Password reset code

password
required
string <password>

New password

Responses

Request samples

Content type
application/json
{
  • "phone": "+123456789012",
  • "code": "a1B2c3E5",
  • "password": "pa$$word"
}

Response samples

Content type
application/json
{
  • "code": [
    ]
}

Laws

List

Authorizations:
query Parameters
page
integer

A page number within the paginated result set.

Responses

Response samples

Content type
application/json
{}

Retrieve

Authorizations:
path Parameters
id
integer >= 1

The law ID

Responses

Response samples

Content type
application/json
{
  • "id": 0,
  • "title": "Title",
  • "content": "<p>Hello<p>",
  • "created_at": "1611590593",
  • "modified_at": "1611590593"
}</