Skip to content

Ticketin/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pocky/backend

See production deployment here: https://pocky.deno.land/

A REST API for Pocky. It does:

  • Store QR codes in the safe place
  • Relay sport API (e.g. ESPN) for the chainlink
  • Fetches sport API initially to construct the collection metadata

Prerequisites

  • Deno 1.34 or higher

Running the Server

Start the server with the command:

deno run --allow-net main.ts

This starts the server at http://localhost:8000/

Deploying the Server

As new commits pushed into main branch, Deno deploys it automatically.

API Documentation

GET /api/sport/nba/:matchDate

Fetches the metadata and the result of a match. The matchDateis YYYYMMDD format. For response format, please refer SportResult.

It is being called by Chainlink Oracle nodes.

Request Example
 $ curl https://pocky.deno.land/api/sport/nba/20230527
Response Example
{
  "hasResult": true,
  "home": {
    "metadata": {
      "name": "Miami Heat",
      "symbol": "MIA",
      "color": "#98002e",
      "logo": "https://a.espncdn.com/i/teamlogos/nba/500/scoreboard/mia.png"
    },
    "score": 103,
    "stats": {
      "fieldGoalsMade": "33",
      "fieldGoalsPct": "35.5%",
      "threePointMade": "14",
      "threePointPct": "46.7%",
      "freeThrowsMade": "23",
      "freeThrowPct": "79.3%"
    }
  },
  "away": {
    "metadata": {
      "name": "Boston Celtics",
      "symbol": "BOS",
      "color": "#006532",
      "logo": "https://a.espncdn.com/i/teamlogos/nba/500/scoreboard/bos.png"
    },
    "score": 104,
    "stats": {
      "fieldGoalsMade": "34",
      "fieldGoalsPct": "43.6%",
      "threePointMade": "7",
      "threePointPct": "20.0%",
      "freeThrowsMade": "29",
      "freeThrowPct": "85.3%"
    }
  }
}
Error Example

When match is not held at given date, it returns HTTP 404 Not Found with NOT_FOUND code.

{
  "error": {
    "code": "NOT_FOUND",
    "message": "event not found"
  }
}

GET /render

Renders given SVG image as HTML. Used for displaying dynamic-rendered SVG on the NFT platforms that doesn't support loading external images inside SVG. (e.g. OpenSea)

Query Parameter
Name Description Required Example
svg Base64 Encoded SVG Image. Yes PHN2ZyB3a...
Request Example
 $ curl https://pocky.deno.dev/render?svg=PHN2ZyB3a...
Response Example
<html>
  <body>
    <svg width="848" height="848" viewBox="0 0 848 848" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      ...
    </svg>
  </body>
</html>