Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

NYCU ME APIs Docs

Cycatz edited this page Feb 25, 2022 · 9 revisions

NYCU-ME APIs Docs

General

現 API Server: api.nycu.me,需 HTTPS

How to pass user token?

Header: Authorization 欄位為 Bearer {token}

Example.

curl https://api.nycu.me/ -H "Authorization: Bearer {token}

JWT Payload

exp, iat, iss, nbf, uid, username, email

Authorization

[GET] Login: /oauth/<string:code>

當你從 portal 登入之後,他會 redirect 到某個 url,其中會傳遞一個 code 參數,你可以使用這個 code 來向 backend 詢問使用者的 token,之後將 token 存入 cookie,在每次呼叫 APIs 時傳入。

Possible Error

Status Code Description
200 Ok and token returned
401 code has expired

Example.

# curl https://api.nycu.me/oauth/{code}
{
  "token": {token}
}

[GET] Get user's information:/auth

Status Code Description
200 Ok and user's data returned
401 not logged or invalid token
{
  "domains": [
    {
      "domainName": {},
      "expDate": {},
      "id": {},
      "regDate": {}
      "records": [
         {
            "ttl": {}, "type": {}, "value": {}
         },
         ...
      ]
    },
    ...
  ],
  "email": {},
  "limit": {},
  "uid": {},
  "username": {}
}

DNS

Error Types:

  • NotAllowedDomain
  • NumberLimitExceed
  • AssignedDomainName
  • PermissionDenied

[POST] Apply Domain Name: /domains/<path:domain>

You would call https://api.nycu.me/domains/me/nycu/test in order to apply test.nycu.me.

You must be logged to do it.

Status Code Description
200 Ok
401 Not logged
403 Logged but not allowed(Error Types below)

Example:

# Calling https://api.nycu.me/domains/me/nctu/test
Status: 403
{
  "errorType": "DNSErrors.NotAllowedDomain",
  "msg": "test.nctu.me is not allowed."
}
# Calling https://api.nycu.me/domains/me/nycu/test
Status: 200
{
  "msg": "ok
}

[DELETE] Release Domain Name: /domains/<path:domain>

Similar to apply one.

You must be logged to do it.

Status Code Description
200 Ok
401 Not logged
403 Logged but not allowed(Error Types below)

Example.

# Calling https://api.nycu.me/domains/me/nycu/test
Status: 403
{
  "errorType": "DNSErrors.AssignedDomainName",
  "msg": "test.nycu.me is not being used."
}
# Calling https://api.nycu.me/domains/me/nycu/test
Status: 200
{
  "msg": "ok"
}

[POST] Renew a domain name: /renew/<path:domain>

You must be logged to do it.

[POST] Add new record: /ddns/<path:domain>/records/<string:type>/<string:value>

You must be logged to do it.

Status Code Description
200 Ok
401 Not logged
403 Logged but not allowed(Error Types below)

Allowed types:

Types Means
A IPv4
AAAA IPv6
CNAME Alias
MX Mail Exchanger
TXT

Example.

# Calling https://api.nycu.me/ddns/me/nycu/test/records/A/140.113.89.32
Status: 200
{
  "msg": "ok"
}

You can pass a JSON in request body, which contains one integer element ttl, where 0 < ttl <= 86400.

[Delete] Delete record: /ddns/<path:domain>/records/<string:type>/<string:value>

Similar to add one.

You must be logged to do it.

Status Code Description
200 Ok
401 Not logged
403 Logged but not allowed(Error Types below)

Example.