Skip to content

An API that returns public data from the Verida network

Notifications You must be signed in to change notification settings

verida/network-data-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verida Network Data API

https://github.com/verida/network-data-api

This is a generic API that fetches public data from the Verida network. It also supports fetching IPFS records uploaded via Moralis.

This server is hosted publicly at: https://data.verida.network

Installation instructions

Set up environment

cp .env.example .env

.env File contains

  • ENABLED_REDIS_CACHE -> Enable Redis cache
  • SERVER_PORT -> Optional, defaults to 8182
  • REDIS_HOST -> hostname of the Redis server
  • REDIS_PORT -> port of the r=Redis server
  • CACHE_DATA_TIMEOUT_SECONDS -> Timeout for cache data entries

Local Redis

Using Docker:

docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest

You can inspect the Redis cache:

> docker restart redis-stack # if needed
> docker ps # get the container ID
> docker exec -it <container id> /bin/sh  # get a shell
> redis-cli # start the the redis cli

To clear all the caches get the redis-cli (as above) and then:

flushdb

Running the server

yarn install
yarn run dev

Run serverless offline

yarn svl-offline

Usage

Make HTTP GET requests to fetch data from the network in the following format:

https://localhost:8182/<did>/<contextName>/<databaseName>/<recordId>/<attribute>/<...deepAttributes>

did, contextName, databaseName and recordId are required. The rest are optional.

If an attribute is specified, just that attribute value from the record is returned.

Deep attributes

deepAttributes represent an unlimited number of levels that can be retrevied with in a JSON result.

Assume there is a record with the following data:

{
    _id: 'test-record',
    data: {
        name: {
            firstName: 'steve',
            lastName: 'jones'
        }
    }
}

It's possible to fetch just lastName with:

/<did>/<contextName>/<databaseName>/test-record/data/name/lastName

Network stats

It's possible to load the stats for a particular network:

/network/testnet/stats

Examples

Fetch a record

Fetch a user's public profile:

/did:vda:testnet:0x84746Ff2bC4E998fB23815f242d192912076e767/Verida:%20Vault/profile_public/basicProfile

This returns the full record with _id=basicProfile

{
  "_id": "basicProfile",
  "_rev": "13-402d249600cfe3984a6a90e459d348dc",
  "avatar": { "uri": "data:image/undefined;base64,/9j/4A....<truncated>" },
  "country": "Australia",
  "description": "Help building user-centric and privacy-preserving applications with Verida",
  "modifiedAt": "2023-03-03T04:50:32.227Z",
  "name": "Aurel",
  "schema": "https://common.schemas.verida.io/profile/basicProfile/v0.1.0/schema.json",
  "signatures": {
    "did:vda:testnet:0x84746ff2bc4e998fb23815f242d192912076e767?context=0x3c51af440094f5e93e3421504b8203228804ea2bbcfb11a2790d25e5f8898f01": "0x4d173694cf32990e7fcea45b46da5f6b9af507a2ffc3904b3c71bf1a87817f7f671b55bc820c17a68384467039dddda4aaa5fada898fb91c0013fe44daf934ab1b"
  }
}

Fetch the attribute for a record

Fetch a user's public profile avatar:

/did:vda:testnet:0x84746Ff2bC4E998fB23815f242d192912076e767/Verida:%20Vault/profile_public/basicProfile/avatar

This returns just the avatar attribute from the public profile record:

{ "avatar": { "uri": "data:image/undefined;base64,/9j/4A....<truncated>" } }

Fetch a deep attribute for a record

/did:vda:testnet:0x84746Ff2bC4E998fB23815f242d192912076e767/Verida:%20Vault/profile_public/basicProfile/avatar/uri

Returns just the uri part of the avatar attribute

{ "avatar": { "uri": "data:image/undefined;base64,/9j/4A....<truncated>" } }

Fetch IFPS data

https://data.verida.network/ipfs/QmezTsjRwoi5XoqYLCH6sz4RSjXDUMXWGGFrVDxZh19p9j

Deployment

As a Lambda (but see #6 (comment)):

nvm use
export AWS_PROFILE=verida-original
yarn deploy-prod

About

An API that returns public data from the Verida network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published