Skip to content

exah/piny-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚧 This is work in progress


🌲 piny.link

API server for tiny bookmarking service

Requirements

Quick start

Install dependencies:

npm install

Create empty database:

npm run sync

Start dev server:

KEY="secret-key" npm run dev

Production:

KEY="secret-key" npm start

API

This doc assume that your server running on https://dev.piny.link. The request examples uses httpie.

Emoji key:

  • 🌍 Public endpoint
  • πŸ” Requires authorisation

Headers:

  • Content-Type: application/json β€” default body type
  • Authorization: Bearer XXX β€” replace XXX with token from /login response (πŸ” restricted endpoints only)

🌍 Create user

POST /signup

Body

  • user: string β€” user name (unique)
  • pass: string β€” user password (no restrictions)
  • email: string β€” user email (unique)

Request

http --json POST 'https://dev.piny.link/signup' \
  'Content-Type':'application/json' \
  user="foo" \
  pass="1234" \
  email="[email protected]"

Response

201
{
  "message": "πŸ‘‹ Welcome, please /login"
}

🌍 Log in

POST /login

Body

  • user: string β€” user name
  • pass: string β€” user password

Request

http --json POST 'https://dev.piny.link/login' \
  'Content-Type':'application/json' \
  pass="1234" \
  user="foo"

Response

200
{
  "token": "XXX",
}

πŸ” Log out

GET /logout

Request

http GET 'https://dev.piny.link/logout' \
  'Authorization':'Bearer XXX'

Response

200
{
  "message": "πŸ‘‹ Bye"
}

πŸ” Get user

GET /:user

Params

  • user: string β€” user name

Request

http GET 'https://dev.piny.link/:user' \
  'Authorization':'Bearer XXX'

Response

200
{
  "id": "YYY",
  "name": "foo",
  "email": "[email protected]"
}

🌍/πŸ” Get user bookmarks

GET /:user?/bookmarks

Params

  • user?: string β€” user name (if omitted, get bookmarks of current user)

Request

http GET 'https://dev.piny.link/:user/bookmarks' \
  'Authorization':'Bearer XXX'

Response

200
[
  {
    "id": "ff7b3bb2-5fad-4924-81a6-5bedc3ded3dd",
    "title": "KayWay",
    "description": "Illustration portfolio by Ekaterina Grishina",
    "state": "active",
    "privacy": "public",
    "link": {
      "id": "a6f7584f-c1a5-42e8-bd98-e1bb003fc219",
      "url": "https://kayway.me/"
    },
    "tags": [
      {
        "id": "2c00e362-30fc-4dba-89ed-24c0a3d11ab4",
        "name": "illustrator"
      },
      {
        "id": "823e8339-2296-4972-aeed-951df1826228",
        "name": "portfolio"
      }
    ],
    "createdAt": "2020-08-02T00:34:45.000Z",
    "updatedAt": "2020-08-02T00:34:45.000Z"
  },
  ...
]

πŸ” Get user tags

GET /:user/tags

Params

  • user: string β€” user name

Request

http GET 'https://dev.piny.link/:user/tags' \
  'Authorization':'Bearer XXX'

Response

200
[
  {
    "id": "2c00e362-30fc-4dba-89ed-24c0a3d11ab4",
    "name": "illustrator"
  },
  {
    "id": "823e8339-2296-4972-aeed-951df1826228",
    "name": "portfolio"
  }
]

πŸ” Create bookmark

POST /bookmarks

Body

  • url: string β€” bookmark url
  • title?: string β€” bookmark title (optional)
  • description?: string β€” bookmark description (optional)
  • privacy: 'public' β€” access to bookmark (only 'public' supported at the moment)
  • tags?: string[] β€” list of tags that should be assigned to the bookmark, will be added to the user tags (optional)

Request

http --json POST 'https://dev.piny.link/bookmarks' \
  'Authorization':'Bearer XXX' \
  'Content-Type':'application/json' \
  title="KayWay" \
  description="Illustration portfolio by Ekaterina Grishina" \
  url="https://kayway.me" \
  privacy="public" \
  tags:="[
    \"illustrator\",
    \"portfolio\"
  ]"

Response

201
{
  "message": "✨ Created"
}

πŸ” Edit bookmark

PATCH /bookmarks/:id

Params

  • id: string β€” bookmark id

Body

  • url?: string β€” bookmark url (optional)
  • title?: string β€” bookmark title (optional)
  • description?: string β€” bookmark description (optional)
  • privacy?: 'public' β€” access to bookmark (only 'public' supported at the moment) (optional)
  • tags?: string[] β€” list of tags that should be assigned to the bookmark, will be added to the user tags (optional)

Request

http --json PATCH 'https://dev.piny.link/bookmarks/:id' \
  'Authorization':'Bearer XXX' \
  'Content-Type':'application/json' \
  title="KayWay" \
  description="Illustration portfolio by Ekaterina Grishina" \
  tags:="[
    \"illustrator\",
    \"portfolio\"
  ]"

Response

200
{
  "message": "πŸ’Ύ Saved"
}

πŸ” Delete bookmark

DELETE /bookmarks/:id

Params

  • id: string β€” bookmark id

Request

http DELETE 'https://dev.piny.link/bookmarks/:id' \
  'Authorization':'Bearer XXX'
200
{
  "message": "πŸ—‘ Removed"
}

Β© Ivan Grishin

About

API server for tiny bookmarking service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published