Skip to content

Commit 24725f5

Browse files
committed
feat: tokens route for getting IDs
1 parent c9d5a1f commit 24725f5

File tree

5 files changed

+524
-64
lines changed

5 files changed

+524
-64
lines changed

cmd/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func RunApi(cmd *cobra.Command, args []string) {
9292
// token holder queries
9393
root.GET("/holders/:address", handlers.GetTokenHoldersByType)
9494

95+
// token ID queries
96+
root.GET("/tokens/:address", handlers.GetTokenIdsByType)
97+
9598
// search
9699
root.GET("/search/:input", handlers.Search)
97100
}

docs/docs.go

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ const docTemplate = `{
747747
"type": "string",
748748
"description": "Type of token",
749749
"name": "token_type",
750-
"in": "path"
750+
"in": "query"
751751
},
752752
{
753753
"type": "boolean",
@@ -813,6 +813,109 @@ const docTemplate = `{
813813
}
814814
}
815815
},
816+
"/{chainId}/tokens/{address}": {
817+
"get": {
818+
"security": [
819+
{
820+
"BasicAuth": []
821+
}
822+
],
823+
"description": "Retrieve token IDs by type for a specific token address",
824+
"consumes": [
825+
"application/json"
826+
],
827+
"produces": [
828+
"application/json"
829+
],
830+
"tags": [
831+
"tokens"
832+
],
833+
"summary": "Get token IDs by type for a specific token address",
834+
"parameters": [
835+
{
836+
"type": "string",
837+
"description": "Chain ID",
838+
"name": "chainId",
839+
"in": "path",
840+
"required": true
841+
},
842+
{
843+
"type": "string",
844+
"description": "Token address",
845+
"name": "address",
846+
"in": "path",
847+
"required": true
848+
},
849+
{
850+
"type": "string",
851+
"description": "Type of token (erc721 or erc1155)",
852+
"name": "token_type",
853+
"in": "query"
854+
},
855+
{
856+
"type": "boolean",
857+
"description": "Hide zero balances",
858+
"name": "hide_zero_balances",
859+
"in": "query",
860+
"required": true
861+
},
862+
{
863+
"type": "integer",
864+
"description": "Page number for pagination",
865+
"name": "page",
866+
"in": "query"
867+
},
868+
{
869+
"type": "integer",
870+
"default": 5,
871+
"description": "Number of items per page",
872+
"name": "limit",
873+
"in": "query"
874+
}
875+
],
876+
"responses": {
877+
"200": {
878+
"description": "OK",
879+
"schema": {
880+
"allOf": [
881+
{
882+
"$ref": "#/definitions/api.QueryResponse"
883+
},
884+
{
885+
"type": "object",
886+
"properties": {
887+
"data": {
888+
"type": "array",
889+
"items": {
890+
"$ref": "#/definitions/handlers.TokenIdModel"
891+
}
892+
}
893+
}
894+
}
895+
]
896+
}
897+
},
898+
"400": {
899+
"description": "Bad Request",
900+
"schema": {
901+
"$ref": "#/definitions/api.Error"
902+
}
903+
},
904+
"401": {
905+
"description": "Unauthorized",
906+
"schema": {
907+
"$ref": "#/definitions/api.Error"
908+
}
909+
},
910+
"500": {
911+
"description": "Internal Server Error",
912+
"schema": {
913+
"$ref": "#/definitions/api.Error"
914+
}
915+
}
916+
}
917+
}
918+
},
816919
"/{chainId}/transactions": {
817920
"get": {
818921
"security": [
@@ -1359,12 +1462,18 @@ const docTemplate = `{
13591462
"indexedParams": {
13601463
"type": "object"
13611464
},
1465+
"indexed_params": {
1466+
"type": "object"
1467+
},
13621468
"name": {
13631469
"type": "string"
13641470
},
13651471
"nonIndexedParams": {
13661472
"type": "object"
13671473
},
1474+
"non_indexed_params": {
1475+
"type": "object"
1476+
},
13681477
"signature": {
13691478
"type": "string"
13701479
}
@@ -1678,6 +1787,9 @@ const docTemplate = `{
16781787
},
16791788
"token_id": {
16801789
"type": "string"
1790+
},
1791+
"token_type": {
1792+
"type": "string"
16811793
}
16821794
}
16831795
},
@@ -1692,6 +1804,9 @@ const docTemplate = `{
16921804
},
16931805
"token_id": {
16941806
"type": "string"
1807+
},
1808+
"token_type": {
1809+
"type": "string"
16951810
}
16961811
}
16971812
},
@@ -1739,6 +1854,17 @@ const docTemplate = `{
17391854
"SearchResultTypeAddress",
17401855
"SearchResultTypeContract"
17411856
]
1857+
},
1858+
"handlers.TokenIdModel": {
1859+
"type": "object",
1860+
"properties": {
1861+
"token_id": {
1862+
"type": "string"
1863+
},
1864+
"token_type": {
1865+
"type": "string"
1866+
}
1867+
}
17421868
}
17431869
},
17441870
"securityDefinitions": {

docs/swagger.json

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@
740740
"type": "string",
741741
"description": "Type of token",
742742
"name": "token_type",
743-
"in": "path"
743+
"in": "query"
744744
},
745745
{
746746
"type": "boolean",
@@ -806,6 +806,109 @@
806806
}
807807
}
808808
},
809+
"/{chainId}/tokens/{address}": {
810+
"get": {
811+
"security": [
812+
{
813+
"BasicAuth": []
814+
}
815+
],
816+
"description": "Retrieve token IDs by type for a specific token address",
817+
"consumes": [
818+
"application/json"
819+
],
820+
"produces": [
821+
"application/json"
822+
],
823+
"tags": [
824+
"tokens"
825+
],
826+
"summary": "Get token IDs by type for a specific token address",
827+
"parameters": [
828+
{
829+
"type": "string",
830+
"description": "Chain ID",
831+
"name": "chainId",
832+
"in": "path",
833+
"required": true
834+
},
835+
{
836+
"type": "string",
837+
"description": "Token address",
838+
"name": "address",
839+
"in": "path",
840+
"required": true
841+
},
842+
{
843+
"type": "string",
844+
"description": "Type of token (erc721 or erc1155)",
845+
"name": "token_type",
846+
"in": "query"
847+
},
848+
{
849+
"type": "boolean",
850+
"description": "Hide zero balances",
851+
"name": "hide_zero_balances",
852+
"in": "query",
853+
"required": true
854+
},
855+
{
856+
"type": "integer",
857+
"description": "Page number for pagination",
858+
"name": "page",
859+
"in": "query"
860+
},
861+
{
862+
"type": "integer",
863+
"default": 5,
864+
"description": "Number of items per page",
865+
"name": "limit",
866+
"in": "query"
867+
}
868+
],
869+
"responses": {
870+
"200": {
871+
"description": "OK",
872+
"schema": {
873+
"allOf": [
874+
{
875+
"$ref": "#/definitions/api.QueryResponse"
876+
},
877+
{
878+
"type": "object",
879+
"properties": {
880+
"data": {
881+
"type": "array",
882+
"items": {
883+
"$ref": "#/definitions/handlers.TokenIdModel"
884+
}
885+
}
886+
}
887+
}
888+
]
889+
}
890+
},
891+
"400": {
892+
"description": "Bad Request",
893+
"schema": {
894+
"$ref": "#/definitions/api.Error"
895+
}
896+
},
897+
"401": {
898+
"description": "Unauthorized",
899+
"schema": {
900+
"$ref": "#/definitions/api.Error"
901+
}
902+
},
903+
"500": {
904+
"description": "Internal Server Error",
905+
"schema": {
906+
"$ref": "#/definitions/api.Error"
907+
}
908+
}
909+
}
910+
}
911+
},
809912
"/{chainId}/transactions": {
810913
"get": {
811914
"security": [
@@ -1352,12 +1455,18 @@
13521455
"indexedParams": {
13531456
"type": "object"
13541457
},
1458+
"indexed_params": {
1459+
"type": "object"
1460+
},
13551461
"name": {
13561462
"type": "string"
13571463
},
13581464
"nonIndexedParams": {
13591465
"type": "object"
13601466
},
1467+
"non_indexed_params": {
1468+
"type": "object"
1469+
},
13611470
"signature": {
13621471
"type": "string"
13631472
}
@@ -1671,6 +1780,9 @@
16711780
},
16721781
"token_id": {
16731782
"type": "string"
1783+
},
1784+
"token_type": {
1785+
"type": "string"
16741786
}
16751787
}
16761788
},
@@ -1685,6 +1797,9 @@
16851797
},
16861798
"token_id": {
16871799
"type": "string"
1800+
},
1801+
"token_type": {
1802+
"type": "string"
16881803
}
16891804
}
16901805
},
@@ -1732,6 +1847,17 @@
17321847
"SearchResultTypeAddress",
17331848
"SearchResultTypeContract"
17341849
]
1850+
},
1851+
"handlers.TokenIdModel": {
1852+
"type": "object",
1853+
"properties": {
1854+
"token_id": {
1855+
"type": "string"
1856+
},
1857+
"token_type": {
1858+
"type": "string"
1859+
}
1860+
}
17351861
}
17361862
},
17371863
"securityDefinitions": {

0 commit comments

Comments
 (0)