---
title: 'GraphQL API'
tags: Project Galaxy
---
GraphQL API
===
##### 最后更新于 2021 年 12 月 28 日
## 浏览器
您可以使用 GraphQL Explorer 对 Project Galaxy 数据运行查询,端点如下所示。
此外,在浏览器中创建了一个[游乐场](https://graphigo.stg.galaxy.eco/),其中包括文档、醒目语法和验证错误。您可以找到所有 API 并尝试在其中编写自己的查询。

## Endpoints
正式环境:
https://graphigo.prd.galaxy.eco/query
预备环境:
https://graphigo.stg.galaxy.eco/query
:::info
**获得帮助 ?**
如果您没有找到您要找的东西或需要帮助,请加入电报群以获得更多支持。
[Project Galaxy API Support](https://t.me/+4hYvDKKEGztlNzQx)
:::
## Query 类型
Query 类型包含 API 的所有可执行查询的最上层入口点。
### `Query.campaign`
Find a campaign. Returns `Campaign`.
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `id` | `ID!` | 活动 ID |
示例 :
**Request**
```javascript=
query {
campaign(id: 120) {
id
name
numberID
info
description
requireEmail
status
gasType
startTime
chain
enableWhitelist
}
}
```
**Response**
```javascript=
{
"data": {
"campaign": {
"id": "GCUKoUUbRo",
"name": "50 GTC from GitcoinDAO",
"numberID": 120,
"info": "- Onboard to GitcoinDAO and get 50 GTC for completing an intermediate mission, with mentorship and support from Austin Griffith.\n- To onboard, use this form: https://form.typeform.com/to/E96KbTSy (mention \"shadowy super coder\" under \"specific skills\" section) \n- In addition to the 50 GTC rewards up for grabs, Gitcoin is also offering hands on support for grant creation leading up to GR11.\n",
"description": "- Onboard to GitcoinDAO and get 50 GTC for completing an intermediate mission, with mentorship and support from Austin Griffith.\n- To onboard, use this form: https://form.typeform.com/to/E96KbTSy (mention \"shadowy super coder\" under \"specific skills\" section) \n- In addition to the 50 GTC rewards up for grabs, Gitcoin is also offering hands on support for grant creation leading up to GR11.\n",
"requireEmail": false,
"status": "Draft",
"gasType": "GAS",
"startTime": 1629129600,
"chain": "RINKEBY",
"enableWhitelist": true
}
}
}
```
### `Query.nftCore`
Find a NFT contract. Returns `NFTCore`.
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `address` | `String!` | NFT 合约的地址。 |
示例 :
**Request**
```javascript=
query {
nftCore(address: "0x574E84F1837a69791379eCb9dbC9CB5c5d92b55E") {
id
contractAddress
spaceStationAddress
name
info
symbol
chain
transferable
}
}
```
**Response**
```javascript=
{
"data": {
"nftCore": {
"id": "7",
"contractAddress": "0x574E84F1837a69791379eCb9dbC9CB5c5d92b55E",
"spaceStationAddress": "0x860366952A0CC61196aAA861A71eE7bE3eB6E3eD",
"name": "KOVAN NFT",
"info": "KOVAN NFT",
"symbol": "KN",
"chain": "KOVAN",
"transferable": true
}
}
}
```
### `Query.addressInfo`
Get information about user. Returns `Address`.
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `address` | `String!` | 用户的地址 |
示例 :
**Request**
```javascript=
query {
addressInfo(address: "0x424B279097560001B35cedDB649838FBb8227009") {
id
address
username
hasEmail
eligibleCredentials {
totalCount
pageInfo {
startCursor
endCursor
hasNextPage
}
list {
id
name
chain
description
}
}
}
}
```
**Response**
```javascript=
{
"data": {
"addressInfo": {
"id": "faxHzVB7ded6T8UdkZDyMV",
"address": "0x424B279097560001B35cedDB649838FBb8227009",
"username": "yijun39",
"hasEmail": true,
"eligibleCredentials": {
"totalCount": 0,
"pageInfo": {
"startCursor": "0",
"endCursor": "-1",
"hasNextPage": true
},
"list": []
}
}
}
}
```
### `Query.cred`
Find a credential. Returns `Cred`.
| 名称 | 类别 | 描述 |
| -------- | -------- | --------
| `id` | `ID!` | 凭证的 ID |
示例 :
**Request**
```javascript=
query {
cred(id: 1) {
id
name
description
chain
type
curatorAddress
referenceLink
itemCount
subgraph {
endpoint
query
expression
}
}
}
```
**Response**
```javascript=
{
"data": {
"cred": {
"id": "1",
"name": "Static address cred",
"description": "address cred desc",
"chain": "ETHEREUM",
"type": "ADDRESS",
"curatorAddress": "0x424B279097560001B35cedDB649838FBb8227009",
"referenceLink": "https://www.notion.so/bulletlabs/Frontend-Web-Credential-refactor-7984231881eb41228cb0d82a2bd91cad",
"itemCount": 10,
"subgraph": null
}
}
}
```
## Connections
我们模式中的一些类型是 `Connection` 类型,它们代表了图中两个节点之间分页的 edges 的集合,这些遵循 [Relay cursor connections specification](https://relay.dev/graphql/connections.htm)。
### Pagination arguments
所有 connection fields 都支持以下分页参数:
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `first` | `Int ` | 返回列表中的前 n 个元素。最大值为 1000 |
| `after` | `String`| 返回列表中指定指标 cursor 之后的元素 |
由于这些参数对所有 connection fields 都是通用的,因此不会对每个连接重复它们。
### Connection fields
所有 connections 至少具有以下 fields:
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `totalCount` | `Int ` | 当前页面中的项目总数 |
| `pageInfo` | `PageInfo!`| 分页信息 |
| `edges` | `[edge!]` | |
| `list` | `[item!]` | |
`Edge` 和 `List` 的精确类型取决于连接的类型。 `AddressConnection` 将包含类型为 `[Address!]` 的列表和类型为 `AddressEdge` 的 edges
#### `AddressConnection`
`Address` 的连接类型。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `totalCount` | `Int ` | 当前页面中的地址总数 |
| `edges` | `[AddressEdge!]` | edges 列表 |
| `list` | `[Address!]` | addresses 列表 |
| `pageInfo` | `PageInfo!` | 有助于分页的信息 |
#### `CredItemConnection`
`CredItem` 的连接类型。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `totalCount` | `Int ` | 当前页面中的凭证项目总数 |
| `edges` | `[CredItemEdge!]` | edges 列表 |
| `list` | `[String!]` | addresses 列表 |
| `pageInfo` | `PageInfo!` | 有助于分页的信息 |
## Object 类型
Object 类型表示 Project Galaxy API 可以返回的资源。它们包含 fields。每个 fields 都有自己的类型,可以是基本的 GraphQL [标量类型](https://graphql.org/learn/schema/#scalar-types)之一(例如: `String` 或 `Boolean`)或其他 Object 类型。Fields 可能有参数。带参数的 Fields 与最上层查询完全一样,并列在每个对 Object 类型的 fields 表下方。
#### `Address`
Address 的详细信息。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `id` | `ID!` | 地址 ID |
| `address` | `String` | 地址本身 |
| `username` | `String` | 地址的用户名称 |
| `haseEmail` | `Boolean` | 地址是否有电子邮件 |
| `email` | `String` | 地址的电子邮件 |
| `avatar` | `String` | 地址的头像 |
| `eligibleCredentials` | `CredConnection!` | 地址的资格凭证 |
#### `Campaign`
Campaign 的详细信息。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `id` | `ID!` | 活动 ID |
| `name` | `String` | 活动名称 |
| `info` | `String` | 活动信息 |
| `description` | `String` | 活动描述 |
| `gasType` | `String` | 活动 Gas 类型。 |
| `holders` | `AddressConnection!` | 活动的 NFT 持有者地址 |
#### `Cred`
Cred 的详细信息。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `id` | `ID!` | 凭证 ID |
| `name` | `String` | 凭证名称 |
| `description` | `String` | 凭证描述 |
| `chain` | `Chain!` | 凭证所在链 |
| `type` | `String` | 凭证类别 |
| `curatorAddress` | `String` | 凭证的管理人地址 |
| `referenceLink` | `String` | 凭证的参考链接 |
| `items` | `CredItemConnection!` | 凭证的地址列表 |
#### `NFTCore`
NFT 合约的详细信息。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `id` | `ID!` | NTF 合约 ID |
| `contractAddress` | `String` | NFT 合约地址 |
| `name` | `String!` | NFT 合约名称 |
| `info` | `String!` | NFT 合约信習 |
| `symbol` | `String!` | NFT 合约的符号 |
| `chain` | `Chain!` | NFT 合约的链 |
| `marketLink` | `String!` | NFT 合约的市场链接 |
| `transferable` | `Boolean!` | NFT 是否可以转移 |
#### `PageInfo`
有关连接中的分页信息。
| 名称 | 类别 | 描述 |
| -------- | -------- | -------- |
| `endCursor` | `String` | 分页向前时,指标继续 |
| `hasNextPage` | `Boolean!` | 分页向前时,是否有更多项目? |
| `hasPreviousPage` | `Boolean!` | 分页向后时,是否有更多项目? |
| `startCursor` | `String` | 分页向后时,指标继续 |