The SPP Backend API is a project that provides an API used by the SeeDAO SeePASS service. It allows users to interact with the SeePASS service by providing various endpoints for managing profile information.
To install the project dependencies, run the following command:
$ yarn install
The API service requires a PostgreSQL database to store profile information. Make sure the database service is available at the specified endpoint.
The database configuration is passed to the project via the DATABASE_URL environment variable. Here is an example of how to set it:
export DATABASE_URL="postgres://spp_user:spp_pass@localhost/spp_db?sslmode=0"
Note: Make sure to update the credentials, host, and database name to match your specific environment.
This project uses Prisma as the database ORM, which can handle database initialization tasks. To initialize the database, run the following command:
yarn prisma db push
This will set up the database appropriately if no error.
Before launching the application, those environment variables are required to start the service:
DATABASE_URL: Defines the database url used for the service. The databse service tested with is Postgres 16. Also please make sure the database specified here is same with init phase.
CACHE_SERVICE: Defines the cache component used by service. Currently the only allowed options are:
- memory: indicate the service use internal memory for caching
- redis connection string: indicate the service use some redis service for caching.
Here are a sample:
export DATABASE_URL="postgres://spp_user:spp_pass@localhost/spp_db?sslmode=0"
export CACHE_SERVICE="redis://redis"
#export CACHE_SERVICE="memory"
To start the service, you can use the following commands:
yarn start
or
yarn start:dev
Choose the appropriate command based on your requirements and environment.
SeePASS backend API provides two public endpoints to provide structured data, here are the data description, data schema, and sample response.
This API returns user profile and social network data, which supports passing both wallet address and SNS name. Here are the supported request methods and endpoint:
GET /profile/<wallet addr>
GET /profile/<sns name>
Here is the response format:
curl https://test-seepass-api.seedao.tech/profile/<wallet address> | jq
{
"wallet": "<Wallet Address>",
"nickname": "Vincent",
"bio": "",
"sns_name": "",
"avatar": "<avatar imamge url>",
"email": "<email>",
"snRecords": [
{
"network": "wechat",
"identity": ""
},
{
"network": "discord",
"identity": ""
},
{
"network": "twitter",
"identity": ""
},
{
"network": "mirror",
"identity": ""
}
]
}Here are the details of the fields (itatic means nullable):
| Field | Type | Description | Sample |
|---|---|---|---|
| wallet | string | Wallet string of this user | 0x608a9358354A93581E686ac7fFdE9D5FADbcb7E0 |
| nickname | string | nick name | Vincent |
| bio | string | brief instruction | |
| sns_name | string | sns name | |
| avatar | string | avatar image link | |
| string | email address | ||
| snRecords | Array |
And here is the definition of SocialAccount
| Field | Type | Description | Sample |
|---|---|---|---|
| network | string | social network name | |
| identity | string | network identity | Vincent |
Currently supported social networks are Twitter, Discord, WeChat, Mirror, etc.
This API returns user profiles, social network data, and chain data which also supports passing both wallet address and SNS name. Here are the supported request methods and endpoint:
GET /seepass/<wallet addr>
GET /seepass/<sns name>
Here is a response example with server data:
{
"sns": "<SNS>",
"wallet": "<Wallet Address>",
"avatar": "<Avatar Image URL>",
"email": "<Email>",
"nickname": "Vincent",
"bio": "<Personal BIO>",
"roles": [
"NODE_S4",
"NODE_S2",
"NODE_S3",
"CITYHALL_S3",
"SEEDAO_MEMBER"
],
"scr": {
"amount": "704165",
"contract_addr": "0xc74DEE15a4700D5df797bDD3982EE649A3Bb8c6C"
},
"level": {
"current_lv": "4",
"next_lv": "5",
"scr_to_next_lv": "295835",
"upgrade_percent": "57.73"
},
"seed": [
{
"token_id": "499",
"contract_addr": "0x30093266E34a816a53e302bE3e59a93B52792FD4",
"contract_type": "erc721",
"image_uri": "ipfs://bafybeihwciazjns5wjehd3464ipqzxn2kzutazj2ovk3bol4oxjvpcl5za/499_3.png",
"token_amount": "1"
}
],
"sbt": [
{
"token_id": "42",
"contract_addr": "0x2221F5d189c611B09D7f7382Ce557ec66365C8fc",
"contract_type": "erc1155",
"image_uri": "",
"token_amount": "1",
"collection_name": null,
"name": "SeeDAO",
"symbol": "",
"metadata": {}
},
{
"token_id": "1",
"contract_addr": "0x2221F5d189c611B09D7f7382Ce557ec66365C8fc",
"contract_type": "erc1155",
"image_uri": "https://storage.googleapis.com/ensoul-labs-image/FkboaQ7VEAI_3Nd 1.png",
"token_amount": "1",
"collection_name": null,
"name": "SeeDAO社区大会2.0第0期 - 参与者",
"symbol": "",
"metadata": {
"name": "SeeDAO社区大会2.0第0期 - 参与者",
"image": "https://storage.googleapis.com/ensoul-labs-image/FkboaQ7VEAI_3Nd 1.png",
"properties": {
"category": "社区大会"
},
"description": "SeeDAO社区大会2.0第0期参会成员"
}
},
{
"token_id": "11",
"contract_addr": "0x2221F5d189c611B09D7f7382Ce557ec66365C8fc",
"contract_type": "erc1155",
"image_uri": "https://storage.googleapis.com/ensoul-labs-image/11x386picture.jpg",
"token_amount": "1",
"collection_name": null,
"name": " SeeDAO研发公会 - 2023Q1 Tech Department Attender",
"symbol": "",
"metadata": {
"name": " SeeDAO研发公会 - 2023Q1 Tech Department Attender",
"image": "https://storage.googleapis.com/ensoul-labs-image/11x386picture.jpg",
"properties": {
"category": "研发公会"
},
"description": "2023年Q1研发公会参与者,感谢各位的积极参与。"
}
}
],
"social_accounts": [
{
"network": "wechat",
"identity": ""
},
{
"network": "discord",
"identity": ""
},
{
"network": "twitter",
"identity": ""
},
{
"network": "mirror",
"identity": ""
}
]
}
Here is the description of response fields.
| Field | Type | Description | Sample |
|---|---|---|---|
| wallet | string | Wallet string of this user | 0x608a9358354A93581E686ac7fFdE9D5FADbcb7E0 |
| nickname | string | nick name | Vincent |
| bio | string | brief instruction | |
| sns | string | sns name | |
| avatar | string | avatar image link | |
| string | email address | ||
| roles | Array | user roles in SeeDAO | |
| scr | ScrData | user scr amount and token address | |
| level | LevelData | user SeeDAO level info | |
| seed | Array | User SEED NFT records | |
| sbt | Array | User SeeDAO SBT records | |
| social_accounts | Array | Social accounts list |
Here are the detailed info for various fields:
ScrData
| Field | Type | Description | Sample |
|---|---|---|---|
| amount | string | amount of SCR the user held | 1024 |
| contract | string | SCR contract address | 0xc74DEE15a4700D5df797bDD3982EE649A3Bb8c6C |
LevelData
| Field | Type | Description | Sample |
|---|---|---|---|
| current_lv | string | current level of user | 1 |
| next_lv | string | next level of user | 2 |
| scr_to_next_lv | string | how many SCR credits are required for upgrade | 12345 |
| upgrade_percent | string | percent value of progress in upgrading | 42.24 |
SeedData
| Field | Type | Description | Sample |
|---|---|---|---|
| token_id | string | token ID of this seed | 42 |
| contract_addr | string | contract address of SEED | 0x30093266E34a816a53e302bE3e59a93B52792FD4 |
| contract_type | string | contract type of SEED | erc721 |
| image_uri | string | image URI for SEED NFT | |
| token_amount | string | how many amout is held by user | 1 |
SbtData
| Field | Type | Description | Sample |
|---|---|---|---|
| token_id | string | token ID of this seed | 42 |
| contract_addr | string | contract address of SEED | 0x30093266E34a816a53e302bE3e59a93B52792FD4 |
| contract_type | string | contract type of SEED | erc721 |
| image_uri | string | image URI for SEED NFT | |
| token_amount | string | how many amout is held by user | 1 |
| collection_name | string | NFT collection name | SeeDAO |
| symbol | string | NFT symbol | |
| metadata | object | NFT metadata |
SocialAccount
| Field | Type | Description | Sample |
|---|---|---|---|
| network | string | social network name | |
| identity | string | network identity | Vincent |