test
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Flamby (Government)’s API documentation This is the documentation for [Flamby (Government)](https://flamxby.herokuapp.com/docs)’s API. #### Contents - [Overview](#1-overview) - [Authentication](#2-authentication) - [JWT tokens]() - [Resources](#3-resources) - [Users](#31-users) - [Reservations]() ## 1. Overview Flamby (Government)’s API is a JSON-based API. All requests are made to endpoints beginning: `https://flamxby.herokuapp.com/` All requests must be secure, i.e. `https`, not `http`. ## 2. Authentication In order to access some functions, you will need an access token. An access token grants limited access to a user’s account. We offer one way to acquire an access token: **JWT tokens**. ### 2.1. JWT tokens If you already have an existing integration, the first step is to acquire a short term authorization code by sending the user to our authorization URL so they can grant access to your integration. ``` https://flamxby.herokuapp.com/user/ ``` With the following request body: | Field | Type | Required? | Description | |------------|--------|-----------|------------------------------------------------------------| | name | string | required | The name of the user e.g., "Peter" | | surname | string | required | The surname of the user e.g., "Parker" | | citizen_id | string | required | The citizen id of the user (13 digits) e.g., "1134506547512" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | occupation | string | required | The occupation of the user e.g., "Doctor" | | address | string | required | The address of the user e.g., "Bangkok" | | password | string | required | The password of the user e.g., "Verystrongpassword" | The following permissions are available: | Permission | Description | | -------------------| ------------------------------------------------------------------ | | Create reservation | Grants the ability to create a reservation. | | Update reservation | Grants the ability to update a reservation. | | Delete reservation | Grants the ability to delete a reservation. | Once you have an authorization code, you may exchange it for a 60 minute access token with which you can make authenticated requests on behalf of the user. To acquire an access token, make a form-encoded server-side POST request: ``` POST /login HTTP/1.1 Host: flamxby.herokuapp.com Content-Type: application/x-www-form-urlencoded Accept: application/json Accept-Charset: utf-8 ``` If successful, you will receive back an access token response: ``` HTTP/1.1 201 OK Content-Type: application/json; charset=utf-8 { "access_token": {{access_token}}, "token_type": "bearer", } ``` With the following parameters: | Parameter | Type | Required? | Description | | ------------- |--------------|------------|-------------------------------------------------| | `token_type` | string | required | The literal string "bearer" | | `access_token` | string | required | A token that is valid for 60 minutes and may be used to perform authenticated requests on behalf of the user. | Access tokens is consecutive strings of base 64, like this: ``` eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxODE4MTgxODE4MTgxIiwiZXhwIjoxNjM0OTE5NzEwfQ.It8ku-DPba46Cs-uaB3aFictF-7WrhOtyyNFmxPQbok ``` ## 3. Resources Our API is using RESTful and we arranged around resources. All requests must be made with an integration token and made using `https`. ### 3.1. Users #### Getting the authenticated user’s details Returns details of the user who has granted permission to the application. ``` GET https://flamxby.herokuapp.com/user/{citizen_id} ``` Example request: ``` GET /user/1234123412341 HTTP/1.1 Host: flamxby.herokuapp.com Content-Type: application/json Accept: application/json ``` The response is a User object within a data envelope. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "user_id": 1, "name": "foo", "surname": "rock", "citizen_id": "1234123412341", "occupation": "programmer", "address": "bkk", "reservations": [ { "reservation_id": 1, "register_timestamp": "2021-10-22T14:21:35.372000" } ] } ``` Where a User object is: | Field | Type | Description | |------------|--------|------------------------------------------------------------| | user_id | integer| The id of the user e.g., 1 | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | | reservations | string | The list of the user’s reservations | | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | Possible errors: | Error code | Description | | ---------------------|-------------------------------------------------| | 404 Not found | Send a request but no object was found. | ### 3.2. Reservations #### Listing all the reservation This endpoint lets you get all the reservations of all the users. The REST API endpoint exposes this list of reservations as a collection of resources under the user. A request to fetch a list of reservations for a user looks like this: ``` GET https://flamxby.herokuapp.com/reservation/ ``` The response is a list of the reservations. An empty list is returned if there are no reservations. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 [ { "reservation_id":1, "register_timestamp":"2021-10-22T14:21:35.372000", "owner":{ "name":"foo", "surname":"rock", "birth_date":"2021-10-22", "citizen_id":"1234123412341", "occupation":"programmer", "address":"bkk" } } ] ``` Where a Reservation Object is: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | #### Create a reservation for the user This endpoint lets you create a reservation with the register_timestamp (datetime in ISO format) as a request body. The user needs to be authorized. ``` POST https://flamxby.herokuapp.com/reservation/ ``` With the following request body: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | In the response, the user is presented with the reservation id, register timestamp, and the information of the user. An example response looks like this: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "reservation_id":2, "register_timestamp":"2021-10-22T16:17:13.275000", "owner":{ "name":"pitchapa", "surname":"sae-lim", "birth_date":"2001-05-18", "citizen_id":"1818181818181", "occupation":"engineer", "address":"heaven" } } ``` Where a Reservation Object is: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | Possible errors: | Error code | Description | | ---------------------|-------------------------------------------------| | 404 Not found | Send a request but no object was found.| | 422 Unprocessable Entity| Validation Error | #### Get reservation from reservation's id This endpoint lets you get a specific reservation using the reservation's id as a parameter. A request to fetch a specific reservation using reservation's id looks like this: ``` GET https://flamxby.herokuapp.com/reservation/{reservation_id} ``` With the following parameter: | Parameter | Description | | ------------|-------------------------------------------------| | reservation_id | The id of the specific reservation as an integer e.g., 1| The response is the reservation information with the information of the user that is the owner. A message saying "No reservation with this id" is returned if there are no reservations with the specific id. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "reservation_id":1, "register_timestamp":"2021-10-22T14:21:35.372000", "owner":{ "name":"foo", "surname":"rock", "birth_date":"2021-10-22", "citizen_id":"1234123412341", "occupation":"programmer", "address":"bkk" } } ``` Where a Reservation Object is: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | Possible errors: | Error code | Description | | ---------------------|-------------------------------------------------| | 404 Not found | Send a request but no object was found.| #### Update reservation from reservation's id This endpoint lets you update a specific reservation using the reservation's id as a parameter. The user needs to be authorized. A request to update the reservations with a specific id looks like this: ``` PUT https://flamxby.herokuapp.com/reservation/{reservation_id} ``` With the following parameter: | Parameter | Description | | ------------|-------------------------------------------------| | reservation_id | The id of the specific reservation as an integer e.g., 1| With the following request body: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | The response is the updated reservation information with the information of the user that is the owner. A message saying "No reservation with this id" is returned if there are no reservations with the specific id. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "reservation_id":1, "register_timestamp":"2022-10-22T16:32:46.144000", "owner":{ "name":"pitchapa", "surname":"sae-lim", "birth_date":"2001-05-18", "citizen_id":"1818181818181", "occupation":"engineer", "address":"heaven" } } ``` Where a Reservation Object is: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | Possible errors: | Error code | Description | | ---------------------|-------------------------------------------------| | 401 Unauthorized |Send a request but not authenticated.| | 404 Not found | Send a request but no object was found.| | 422 Unprocessable Entity| Validation Error | #### Delete reservation from reservation's id This endpoint lets you delete a specific reservation using the reservation's id as a parameter. The user needs to be authorized. A request to delete the reservations with a specific id looks like this: ``` DELETE https://flamxby.herokuapp.com/reservation/{reservation_id} ``` The response is a message saying "Delete successfully". A message saying "No reservation with this id" is returned if there are no reservations with the specific id. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 "Delete Successfully" ``` #### Get reservation from specific date This endpoint lets you get a list of reservations using the year, month, and day as a parameter. A request to fetch the list of reservations using year month, and day looks like this: ``` GET https://flamxby.herokuapp.com/reservation/{year}/{month}/{day} ``` With the following parameter: | Parameter | Description | | ------------|-------------------------------------------------| | year | The year of the specific reservation as an integer e.g., 2020| | month | The month of the specific reservation as an integer e.g., 10| | day | The day of the specific reservation as an integer e.g., 21| The response is the list of reservations information with the information of the user that is the owner. An empty list is returned if there are no reservations with the specific year, month, and day. Example response: ``` HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 [ { "reservation_id":1, "register_timestamp":"2023-10-22T16:32:46.144000", "owner":{ "name":"pitchapa", "surname":"sae-lim", "birth_date":"2001-05-18", "citizen_id":"1818181818181", "occupation":"engineer", "address":"heaven" } } ] ``` Where a Reservation Object is: | Field | Type | Description | | ------------|--------|-------------------------------------------------| | reservation_id | integer | The id of the specific reservation e.g., 1 | | register_timestamp | datetime | The datetime as an ISO format e.g., "2021-10-22T14:52:14.933Z" | | name | string | The name of the user e.g., "Peter" | | surname | string | The surname of the user e.g., "Parker" | | birth_date | date | required | The birthdate of the user e.g., "2001-08-21" | | citizen_id | string | The citizen id of the user (13 digits) e.g., "1134506547512" | | occupation | string | The occupation of the user e.g., "Doctor" | | address | string | The address of the user e.g., "Bangkok" | Possible errors: | Error code | Description | | ---------------------|-------------------------------------------------| | 422 Unprocessable Entity| Validation Error |

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully