Skip to content

Latest commit

 

History

History
128 lines (92 loc) · 3.28 KB

README.md

File metadata and controls

128 lines (92 loc) · 3.28 KB

UP API

This REST API retrieves data related to Universal Profiles from the Lukso Blockchain and serves as a bridge between the blockchain and an AI system that processes and presents the data in a suitable manner. Additionally, it includes a Schema Generator that describes the API according to the OpenAI standard (Swagger).

Quickstart

Run Server

import { UpApi } from './src/UpApi.mjs'
const upApi = new UpApi()
upApi
    .init( { 'environment': 'quickstart' } )
    .start()

Generate OpenAI Schema

import { UpApi } from './src/UpApi.mjs'
const upApi = new UpApi()
const schema = upApi.getOpenAiSchema( { 
    'title': 'My Title',
    'description': `My description`,
    'version': 'v0.0.2',
    'url': 'https://...'
} )
console.log( JSON.stringify( schema, null, 4 ) )

Fetch Data

curl --location 'localhost:4040/getUniversalProfile?address=0xB031363560403179Aac100d51864e27fFF4D7807' \
--header 'x-api-key: ...'

Table of Contents

Features

  • Add Header Api Key through key x-api-key. To set secrets see .init({})
  • OpenAI Schema generator, for Custom GPT integration.
  • Add /health route
  • Add /privacy route. You can find the template here: ./public/privacy.html

Methods

Public methods include init, start, and getOpenAISchema.

init( {} )

The following key/value pairs are editable:

Name Description Required Default Type
environment Is needed to locate the environment variables. For 'developement' it expect a file on ./.env. For staging search in process.env Yes development string [ 'development', 'staging' ]
version The version number of the application No `` (empty string) string

For informations you can find under ./src/data/config.mjs

Returns:

return this

Example:

import { UpApi } from './src/UpApi.mjs'
const upApi = new UpApi()
upApi
    .init( { 'environment': 'quickstart', 'version': 'v0.2' } )
    .start()

start()

Start the server after settings via .init({}).

Example:

import { UpApi } from './src/UpApi.mjs'
const upApi = new UpApi()
upApi
    .init( { 'environment': 'quickstart', 'version': 'v0.2' } )
    .start()

getOpenAISchema

Generate an OpenAI Schema configuration file for Custom GPT integration.

import { UpApi } from './src/UpApi.mjs'
const upApi = new UpApi()
const schema = upApi.getOpenAiSchema( { 
    'title': 'Title',
    'description': `Description`,
    'version': '',
    'url': 'https://...'
} )
console.log( JSON.stringify( schema, null, 4 ) )

License

This project is licensed under the Apache 2.0.