API-User Login and Logoff
Category: API / HTTP API / User Login Logoff Method: HTTP GET, parameters appended to the URL query string Server address example:
http://pug1.4000329988.com
1. Relationship Between the Two Endpoints
The HTTP API uses a "log in first to obtain a credential, then call business endpoints with that credential" scheme. These two endpoints are therefore the entry and exit points of every other API:
| Order | Endpoint | Action URL | Purpose |
|---|---|---|---|
| ① | User Login | StandardApiAction_login.action |
Exchange account and password for the session credential jsession |
| ② | Business endpoints | Various business Actions | Attach jsession to every request |
| ③ | User Logoff | StandardApiAction_logout.action |
Explicitly release the jsession |
account + password
│
▼
┌──────────────┐ jsession ┌──────────────────────┐
│ User Login │ ───────────► │ Call business APIs │
└──────────────┘ └──────────────────────┘
│ done
▼
┌──────────────────┐
│ User Logoff │
└──────────────────┘
If Logoff is never called, the credential still expires on its own once the validity period (4 hours) ends. Calling Logoff explicitly releases the session in good time and prevents sessions from piling up.
2. User Login
2.1 Interface Description
A successful login returns the API credential, which is used for subsequent access to the business interfaces.
- Credential validity: 4 hours
- The credential can be reused within the validity period — no need to log in again before every business call
- Continued use of the interfaces refreshes the validity time
- Do not obtain credentials too frequently
NOTE: A second login of the same account will not invalidate the
jsessiongenerated by the first login. In other words, multiple valid sessions may coexist for one account.
2.2 Request Example
http://pug1.4000329988.com/StandardApiAction_login.action?account=testapi&password=testapi
2.3 Request Parameters
| Parameter name | Parameter type | Required | Example | Description |
|---|---|---|---|---|
| account | string | Yes | testapi | User account |
| password | string | Yes | testapi | User password |
2.4 Return Parameters
| Parameter name | Parameter type | Meaning |
|---|---|---|
| result | number | Interface status code. 0 = normal, any other value = error (see Error Code Description) |
| jsession | string | Session number, used when calling business interfaces |
| pri | string | User permissions |
| account_name | string | User account |
| JSESSIONID | string | Session number |
2.5 Return Example
{
"result": 0,
"jsession": "308d1083eca9423e918d381f46b8a8a1",
"pri": ",1,2,24,29,211,213,215,217,676,282,284,219,222,224,23,229,231,233,234,.,",
"account_name": "testapi",
"JSESSIONID": "308d1083eca9423e918d381f46b8a8a1"
}
Note:
priis the list of permission IDs owned by the current account. The real response is very long (several KB), so the middle part is replaced with.in the example above.
2.6 Key Points
jsessionandJSESSIONIDcarry the same value. Use the field namejsessionfor subsequent calls.priis the basis for permission checks and can be cached locally instead of being parsed on every business request.The login response carries no expiry timestamp. Estimate it client-side as "time of the last successful call + 4 hours" and log in again as it approaches.
The password travels in plain text inside the URL — always use HTTPS in production so credentials cannot be captured on the wire.
3. User Logoff
3.1 Interface Description
Logs off the current session and invalidates the corresponding jsession.
3.2 Request Example
http://pug1.4000329988.com/StandardApiAction_logout.action?jsession=308d1083eca9423e918d381f46b8a8a1
3.3 Request Parameters
| Parameter name | Parameter type | Required | Example | Description |
|---|---|---|---|---|
| jsession | string | Yes | 308d1083eca9423e918d381f46b8a8a1 | Session number |
3.4 Return Parameters
| Parameter name | Parameter type | Meaning |
|---|---|---|
| result | number | Interface status code. 0 = success, any other value = error (see Error Code Description) |
3.5 Return Example
{
"result": 0
}
4. Complete Call Flow
4.1 Command Line (curl)
# ① Log in and extract jsession
curl "http://pug1.4000329988.com/StandardApiAction_login.action?account=testapi&password=testapi"
# ② Call a business endpoint with jsession (example: query vehicle information)
curl "http://pug1.4000329988.com/StandardApiAction_queryUserVehicle.action?jsession=308d1083eca9423e918d381f46b8a8a1"
# ③ Log off
curl "http://pug1.4000329988.com/StandardApiAction_logout.action?jsession=308d1083eca9423e918d381f46b8a8a1"
4.2 Python Example
import requests
BASE = "http://pug1.4000329988.com"
# ① Log in
r = requests.get(f"{BASE}/StandardApiAction_login.action",
params={"account": "testapi", "password": "testapi"}, timeout=10)
data = r.json()
if data.get("result") != 0:
raise RuntimeError(f"Login failed: {data}")
jsession = data["jsession"]
# ② Business call
r = requests.get(f"{BASE}/StandardApiAction_queryUserVehicle.action",
params={"jsession": jsession}, timeout=10)
# ③ Log off
requests.get(f"{BASE}/StandardApiAction_logout.action",
params={"jsession": jsession}, timeout=10)
5. FAQ
Q1: Will logging in again kick out the previous session?
No. A second login of the same account does not invalidate the jsession created by the first login, so multiple sessions can coexist. If your program logs in again before every request, sessions will pile up — log in once and reuse the credential instead.
Q2: How long does jsession last?
4 hours. Continuous use of the business interfaces refreshes the validity time; but if no call is made for more than 4 hours, the credential expires and you must log in again.
Q3: A business endpoint returns a non-zero result — is the credential expired?
Not necessarily. A non-zero result means an error occurred, and an expired credential is only one possible cause. Log in again and retry once; if it still fails, check the Error Code Description.
Q4: Login returns result: 0, but a business endpoint says "no permission".
Check whether pri contains the permission ID required by that business endpoint. pri is the account's permission set; if a permission is missing, assign it to the account on the platform.
Q5: Do I have to call Logoff every time? Not required. The credential expires on its own. But for scenarios like "log in once, run one batch job", calling Logoff at the end keeps the session table clean and reduces session buildup.