REST API
- The acronym REST stands for Representational State Transfer, and it's a web service architecture.
- The REST API specifies the ways via which developers can send and receive requests and responses.
- We utilize it for a variety of purposes when we need to transfer JSON-based data from one application to another.
REST SERVICE SPECIFICATION
- Platform-agnostic which means it makes no difference whether the server is Windows, the client is Linux/Android, or something else
- Language-independent communication (C# can communicate with Java, for example).
- Based on industry standards (runs on top of HTTP).
- Even in the presence of firewalls, it is simple to utilize.
JWT(JSON Web Token)
- JSON Web Token (JWT) is a URL-safe way of describing claims to be exchanged between two parties in a concise format.
- The claims in a JWT are encoded as a JavaScript Object Notation (JSON) object, which can then be used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, allowing them to be digitally signed, MACed, and/or encrypted.
- Think of JWT as a simple way to convey information in a clear form (typically in the form of a URL) that can be trusted.
PRE-REQUISITES
- The plugin requires you to install the Nop-Station Core plugin first
INSTALLATION
- Download the nopStation Admin REST API Plugin from our store https://nop-station.com/customer/downloadableproducts
- Upload the NopStation.AdminAPI zip file using the "Upload plugin or theme" button

- Go to Administration, reload the 'list of plugins'. Install 'Nop-Station Core' Plugin first and then install 'Nop-Station Admin API'


- To make the plugins functional, restart the application

- Enable the plugin with the 'Edit' option and Configure it

API DOCUMENTATION
- Postman
- Download Postman Collection.
- Then, just import to the postman and select 'nopStation' environment.
NST Documentation (Step 1 - 3)
This document covers the process of generating a JWT token for NopStation’s Mobile app and explains how these concepts relate to the configuration fields in your store's administration panel.
Step 1: Admin Panel Configuration
This section explains how to configure the Token Key and Secret in your store’s admin panel.
· Go to https://[YOUR_DOMAIN]/Admin/AdminApi/Configure
· Scroll down to the Security section
· Token key could be any string. Keep it a secret.
· Token secret could be any string that is at least 32 characters long. Keep it a secret.
· Check IAT will invalidate the JWT token after every X second. It adds an additional layer of security.
· Important points to consider:
o Do not enable IAT if you want to test the APIs manually from Postman or Swagger.
o The Token Key and Token Secret need to be the same on both the admin panel and in the mobile app’s source code. Otherwise, the app will not connect to the server.
o If your app is already in the Play Store or App Store and you change the Key or Secret, all apps will lose access to the server.
Step 2: JWT Generation Guideline from jwt.io
You’ll need to generate the JWT manually only if you are testing the APIs from Postman or Swagger. If you are not a developer, then it’s not needed.
Step-by-Step Instructions:
1. Navigate to jwt.io: Open your web browser and go to the official tool: https://www.jwt.io/. Select the JWT Encoder tab. It’s not selected by default.
2. Configure the Header: In the Decoded Header section (top left), ensure the algorithm is set to HS256.
JSON
{
"alg": "HS256",
"typ": "JWT"
}
3. Input the Payload: In the Payload section, replace the content with the required claims.
NST_KEY can be any value.
JSON
{
"NST-KEY": "your_token",
"iat": 1516239022
}
4. Configure the Signature (Secret): Scroll down to the Sign JWT section. Enter a Secret key (e.g., "a-string-secret-at-least-32-characters_long"). This secret is used to cryptographically sign the token.
5. Retrieve the Token: The complete Encoded JWT token will be automatically generated and displayed in the JSON Web Token section on the right.
Copy and save the token to use it from Postman or similar tools.
6. In Postman use the generated JWT token in the request header for the key ”NST”.
Explanation of IAT
IAT stands for "Issued At". It specifies the time at which the JWT was created by the client (mobile app). The value is a number, which is a Unix timestamp (the number of seconds elapsed since January 1, 1970 UTC). When a server validates the token, IAT helps to determine how long the token has been active. It also ensures the token wasn't issued too far in the past, often used in conjunction with token expiration for managing lifetime and security policies.
Step 3: Configure the Token Key and Secret on the Mobile App’s Code
The app will generate the JWT token dynamically from the Token Key and Token Secret. Because of that you must have to use the same value in the App’s code and in the admin panel.
· Open lib/networking/api_base_helper.dart
· Change the values of nstKey and nstSecret in the method getRequestHeader
· Double-check that there is no difference between the values in the code and those in the admin panel.
· Compile the project and run the new build.
· If configured correctly, the app will show the homepage. Otherwise, an error will appear.
CONFIGURE
- Go to Admin → NopStation → Plugins → Admin API → Configuration

Security
- Enable JWT security: Check the box to enable JWT Security. It will require 'NST' header for every API request
- Token key: Enter the JSON web token security key. (payload: NST_KEY)
- Token secret: 512 bit JSON web token secret
- Check IAT: Check the checkbox to issue 'At time' timestamp
App settings
- Android version: Enter the current android version published in Google Play Store
- Andriod force update: By marking it as checked, Android users will be forced to update their app when it will not match with the current version published in the Play Store
- Play Store url: Enter the Play store URL for your app
- iOS Version: Enter the current iOS version published in the App Store
- iOS force update: By marking it as checked, iOS users will be forced to update their app when it will not match with the current version published in the App store
- App Store url: Enter the App Store URL for your app
- Logo: Upload the logo to display on the mobile app
- Logo Size: Enter the size of the logo that you want to display