Press / to search

Introduction

REST · JSON · JWT

Welcome to the NEXUS API. This REST API powers Smartstock’s data services. It uses JSON for requests & responses and JWT for authentication. For ease of use, place this calls in a fetch command on your frontend js.

Authentication

JWT

Authenticate using JSON Web Tokens issued by the Token endpoints.

POST/api/token/
{
  "username": "demo",
  "password": "••••••••"
}
// Response
{
  "access": "eyJhbGciOi...",
  "refresh": "eyJ0eXAiOi..."
}
POST/api/token/refresh/
{
  "refresh": "<refresh_token>"
}

Use in Requests

curl -H "Authorization: Bearer <access_token>" \
  bas_url/api/v1/products/

Base URL

Environment

https://nexus.smartstock.africa/

Endpoints

v1

Currency

GET/currency/ List

Returns a json list of currencies with their respective flags in encoded format. Display on html page for visibility of flags.

fetch("https://nexus.smartstock.africa/currency/",{headers: {Authorization: "Bearer access_token"}})"

Query Params

NameTypeDescription
pageintPage index (1-based)
page_sizeintItems per page (max 100)
searchstrFilter by name/sku

Response

{
  "count": 224,
  "next": "bas_url/currency/?page=2",
  "previous": null,
  "results": [
    {"id":1,"currencyCode":"AFN","flag_emoji":"🇦🇫"}
  ]
}
GET/currency/{id}/ Retrieve

Products

GET/api/v1/products/ List

Returns a paginated list of products.

curl -H "Authorization: Bearer <token>" \
bas_url/api/v1/products/?page=1&page_size=20

Query Params

NameTypeDescription
pageintPage index (1-based)
page_sizeintItems per page (max 100)
searchstrFilter by name/sku

Response

{
  "count": 42,
  "next": "bas_url/api/v1/products/?page=2",
  "previous": null,
  "results": [
    {"id":1,"name":"Laptop","price":"1200.00","currency":"USD"}
  ]
}
POST/api/v1/products/ Create
curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Mouse","price":"19.99","currency":"USD"}' \
  bas_url/api/v1/products/
GET/api/v1/products/{id}/ Retrieve
PUT/api/v1/products/{id}/ Update
DELETE/api/v1/products/{id}/ Delete

Error Handling

HTTP
StatusMeaning
200OK
201Created
400Bad Request (validation error)
401Unauthorized (missing/invalid token)
403Forbidden (not allowed)
404Not Found
429Too Many Requests (throttled)
500Server Error

Error Body

{
  "detail": "Authentication credentials were not provided."
}

Pagination

DRF Style

Smartstock uses standard DRF pagination with count, next, previous, and results fields. You can override the page size using ?page_size= (max 100).

Rate Limits

Fair Use

Example policy (configure in DRF):

ActorLimit
Anonymous100 requests / day
Authenticated50 requests / min

Webhooks

Outbound

Register a webhook endpoint to receive Smartstock events.

EventDescription
product.createdFires when a product is created
product.updatedFires when a product is updated
POST https://yourapp.com/webhooks/smartstock
Headers:  Smartstock-Signature: t=..., v1=...
Body:     {"id":1,"name":"Laptop", ...}

Changelog

History
  • v1.1 — Change limits for anonymous users and authenticated users.
  • v1.0 — Initial release: JWT auth, Products CRUD, pagination.
© Smartstock. All rights reserved.