GenoBank.io Docs / Certificates

Back-end service

This is a restful back-end application that allows for querying and mutation GenoBank.io website data and uses 0xcert blockchain gateway endpoint for reading from and writing to Ethereum blockchain.

Property Environment Value
Rinkeby endpoint production https://api.genobank.io
Rinkeby endpoint test https://api-test.genobank.io
Ledger address production 0xcfe0161f1b24cbca200cb4cdd3028fb048ed4b6f
Ledger address test 0x531a972901ed27d49fea8b77276d1418d009f87e
Transaction executor production 0x633F5500A87C3DbB9c15f4D41eD5A33DacaF4184
Transaction executor test 0x795faFFc58648e435E3bD3196C4F75F8EFc4b306

Authentication

All API routes are publicly exposed and anyone can read from and write to the endpoint.

Requests

The server speaks JSON. It’s recommended that every call to the server includes a ContentType header set to application/json; charset=utf-8;.

Requests with POST or PUT method must send data as application/json or multipart/form-data when files are included in the request body.

$ curl -X 'POST' ... \
       -H 'Content-Type: application/json; charset=utf-8' \
       -d $'{}'

Responses

Every response has a unique ID which helps to identify potential problems. It also includes a status code that can help identifying the cause of a potential problem.

Successful requests include a data key, which holds a valid response object, and a meta key, which holds additional information about the result.

{
  "id": ...,
  "status": ...,
  "data": { ... },
  "meta": { ... },
}

In case of failure, the server responds with errors key, which holds a list of error objects.

{
  "id": ...,
  "status": ...,
  "errors": [ ... ]
}

Query requests through GET method can return status codes 200, 400, 401, 403 or 500. Mutations through POST, PUT and DELETE can return also codes 201 and 422. Invalid routes return status code 404.

Error Handling

Errors include a unique code number and an error message. The code number helps identifying potential problems and points to the exact position in the system.

{
  ...
  "errors": [
    {
      "code": 400004,
      "message": "Invalid path."
    }
  ]
}

Routes

Permittees

An permittee is an Ethereum wallet address of a person who owns a biosample token on the blockchain.

POST /permittees/:permitteeId/:permetteeAddress

Creates a new permittee token on the Ethereum blockchain. The request is sent to the blockchain gateway which handles the interaction with the Ethereum blockchain.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

NOTICE: The created transaction will not immediately be available for querying. The request will be first sent to the blockchain and when the transaction is confirmed, the permittee record will be created in the database.

Path variables
Name Description
permitteeId Unique integer number representing a new customer.
permitteeAddress The Ethereum wallet address of a new customer without the prepended 0x.
Body keys
Name Description
permitteeSecret Permittee HMAC secret.

POST /permittees/:permitteeId/public-key

Adds a public key to an existing permittee.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

NOTICE: The wallet address with which permittee message is signed need to be equals to created permittees permitteeAddress.

Path variables
Name Description
permitteeId Unique integer number representing an existing customer.
Body keys
Name Description
signature User signature.
signatureKind Signature type.

GET /permittees/

Returns a paginated list of created permittee objects.

NOTICE: Note that an permittee document is created after its blockchain transaction is confirmed.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.

GET /permittees/:serial

Returns permittee object details.

NOTICE: Note that an permittee document is created after its blockchain transaction is confirmed.

Path variables
Name Description
serial Unique serial number of a permittee.

Biosamples

Each biosample is represented by a biosample token on the Ethereum blockchain.

POST /claim/:tokenId

Creates new biosample and permission token on the Ethereum blockchain. The permission token is automatically assigned to a customer’s wallet address.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

NOTICE: The created transactions will not immediately be available for querying. The request will be first sent to the blockchain and when the transaction is confirmed, the biosample and access records record will be created in the database.

Path variables
Name Description
tokenId The unique token ID for biosample without the prepended 0x.
Body keys
Name Description
signature User signature.
signatureKind Signature type.
seed Seed
biosampleSecret HMAC secret.

GET /biosamples

Returns a paginated list of created biosample objects.

NOTICE: Note that a biosample document is created after its blockchain transaction is confirmed.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.
fromDate A string that when present only items that have creation date greater or equal then specified date (in ISO 8601 format) are returned.
toDate A string that when present only items that have creation date bellow or equal the specified date (in ISO 8601 format) are returned.

GET /biosamples/:serial

Returns biosample object details.

NOTICE: Note that a biosample document is created after its blockchain transaction is confirmed.

Path variables
Name Description
serial Unique serial number of a biosample.

Permissions

Each entity has a permission on the blockchain to access a biosample.

POST /permissions/:tokenId

Creates new permission token on the Ethereum blockchain for a customer.

Note that this functionality is also included in the “Create biosample” route.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

NOTICE: The created transaction will not immediately be available for querying. The request will be first sent to the blockchain and when the transaction is confirmed, the permission document will be created in the database.

Path variables
Name Description
tokenId The unique token ID for permission without the prepended 0x.
Body keys
Name Description
signature User signature.
signatureKind Signature type.
seed Seed

GET /permissions

Returns biosample object details.

NOTICE: Note that a biosample document is created after its blockchain transaction is confirmed.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.
filterPermitteeSerial Filter by permittee serial.
filterOwner Filter by permission token owner address.
filterStatus Filter by permission status.

GET /permissions/:serial

Returns biosample object details.

NOTICE: Note that a biosample document is created after its blockchain transaction is confirmed.

Path variables
Name Description
serial Unique serial number of a permission.

Profiles

Each customer has its own profile.

PUT /profiles/:serial

Creates new profile for a customer.

Path variables
Name Description
serial Unique serial number of a permission.
Body keys
Name Description
text Arbitrary value.
profileSecret HMAC secret.

GET /profiles

Returns a paginated list of profiles.

Query parameters
Name Description
skip An integer which skips the provided number of results.
limit An integer to limits the number of results.
filterSerials An array of serial numbers to include in the result.

GET /profiles/:serial

Returns profile object details.

Path variables
Name Description
serial Unique serial number of a permission.

Token status

All blockchain transactions refer to the same smart contract. This means that all created tokens have the same structure. The status of these tokens is managed by status routes.

POST /status/:tokenId

Updates token status.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

NOTICE: Note that documents are updated after the blockchain transactions are confirmed.

Path variables
Name Description
tokenId The unique token ID for permission without the prepended 0x.
Body keys
Name Description
signature User signature.
signatureKind Signature type.
seed Seed
uri Token status (ACTIVE, INACTIVE).

Documents

Arbitrary documents are uploaded to AWS S3 bucket.

GET /documents

Returns a paginated list of created document objects.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.
filterAddress Owner’s Ethereum address to filter.
filterPermitteeAddress Permittee’s (e.g. laboratory) Ethereum address to filter.

GET /documents/:docId

Returns document object details.

Path variables
Name Description
docId A unique document ID.

POST /documents

Uploads an arbitrary JSON object to the cloud. This routes accepts multipart/form-data content type.

Body keys
Name Description
address Ethereum wallet address without 0x of an owner to which the document belongs to.
permetteeAddress Ethereum wallet address without 0x of a permettee that hass access to it.
source Arbitrary file data.

POST /documents/:docId

Downloads a specific document.

You will need to generate some artifacts to perform this request. Follow the steps below to perform this request:

Path variables
Name Description
docId A unique document ID.

Certificates

Each biosample is represented by a biosample token on the Ethereum blockchain.

POST /certificates

Validates info, timestamps and signs it. If a certificate with the same signature already exists it just return information from that certificate.

Name Description
claim Hash to timestamp.
permitteeSerial Serial of the permittee that signed the claim.
signature Signature made by an permittee of the claim.

GET /certificates

Returns a paginated list of created certificate objects.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.
filterPermitteeSerial Filters result for only specified permittee.
fromDate A string that when present only items that have creation date greater or equal then specified date (in ISO 8601 format) are returned.
toDate A string that when present only items that have creation date bellow or equal the specified date (in ISO 8601 format) are returned.

Counters

Daily counters of creates certificates and biosamples for permittees.

GET /counters

Returns a paginated list of daily counters.

Query parameters
Name Description
skip Skips the provided number of results.
limit Limits the number of results.
filterPermitteeSerial A string[] that filters result for only specified permittees.
fromDate A string that when present only items that have creation date greater or equal then specified date (in ISO 8601 format) are returned.
toDate A string that when present only items that have creation date bellow or equal the specified date (in ISO 8601 format) are returned.
kind A CounterKind that filters result for only specified counter kind.
Counter Kinds
ID Description
1 Certificates.
2 Biosamples.