api

package
v0.0.0-...-1f897c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2018 License: GPL-3.0 Imports: 11 Imported by: 1

README

Blockstack API

The blockstack-api provides a performant interface for fetching data about the Blockstack network. Most of the calls make RPC calls against a configured blockstack-core node and return that data to the user. It can connect to multiple blockstack-core backends at once to enable scaling. It is written in go and utilizes extensive parallelization for speed. It will expose an API as follows:

# implemented
/v1/names/:domainName
# implemented
/v1/names/:domainName/history
# implemented
/v1/namespaces/:namespaceId/names?page=:pageNum
/v2/users/:domainName
/v1/blockchains/bitcoin/operations/:blockHeight

/v1/addresses/bitcoin/:address
/v1/names/:domainName/zonefile
/v1/namespaces/:id
/v1/namespaces
/v1/blockchains/bitcoin/name_count

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(conf blockstack.ServerConfig) *mux.Router

NewRouter returns a router instance to be served

func ResolveProfile

func ResolveProfile(zf *indexer.Zonefile, name string) *indexer.Profile

ResolveProfile takes an initialized domain and fetches the resulting profile for that domain

Types

type Handlers

type Handlers struct {
	Client  *blockstack.Client
	Indexer *indexer.Indexer
	// contains filtered or unexported fields
}

Handlers is a collection of Hanlder

func NewHandlers

func NewHandlers(conf blockstack.ServerConfig) *Handlers

NewHandlers creates the Handlers struct where all the handlers are defined. It is defined this way so database connections and other clients can be shared between handler methods easily

func (*Handlers) V1GetNameHandler

func (h *Handlers) V1GetNameHandler(w http.ResponseWriter, r *http.Request)

V1GetNameHandler handles the /v1/names/{name} route

func (*Handlers) V1GetNameHistoryHandler

func (h *Handlers) V1GetNameHistoryHandler(w http.ResponseWriter, r *http.Request)

V1GetNameHistoryHandler handles response for /v1/names/{name}/history

func (*Handlers) V1GetNameOpsAtHeightHandler

func (h *Handlers) V1GetNameOpsAtHeightHandler(w http.ResponseWriter, r *http.Request)

V1GetNameOpsAtHeightHandler handles response for /v1/blockchains/{blockchain}/operations/{blockHeight} route

func (*Handlers) V1GetNamesInNamespaceHandler

func (h *Handlers) V1GetNamesInNamespaceHandler(w http.ResponseWriter, r *http.Request)

V1GetNamesInNamespaceHandler handles response for /v1/namespaces/{namespace}/names?page={page}

func (*Handlers) V1GetNamesOwnedByAddressHandler

func (h *Handlers) V1GetNamesOwnedByAddressHandler(w http.ResponseWriter, r *http.Request)

V1GetNamesOwnedByAddressHandler handles response for /v1/addresses/bitcoin/{address} route

func (*Handlers) V1GetNamespaceBlockchainRecordHandler

func (h *Handlers) V1GetNamespaceBlockchainRecordHandler(w http.ResponseWriter, r *http.Request)

V1GetNamespaceBlockchainRecordHandler handles response for /v1/namespaces/{namespace} route TODO: seeing some fishy differences between responses from core.blockstack.org and this. I'm copying over the data from the other transactions for the top level object and it looks like core.blockstack.org has data from some other transaction

func (*Handlers) V1GetNamespacesHandler

func (h *Handlers) V1GetNamespacesHandler(w http.ResponseWriter, r *http.Request)

V1GetNamespacesHandler handles response for /v1/namespaces route

func (*Handlers) V1GetZonefileHandler

func (h *Handlers) V1GetZonefileHandler(w http.ResponseWriter, r *http.Request)

V1GetZonefileHandler handles response for /v1/names/{name}/zonefile route

func (*Handlers) V2GetUserProfileHandler

func (h *Handlers) V2GetUserProfileHandler(w http.ResponseWriter, r *http.Request)

V2GetUserProfileHandler handles response for /v2/users/{name} route

type NamespaceTransaction

type NamespaceTransaction struct {
	Address          string `json:"address"`
	Base             int    `json:"base"`
	BlockNumber      int    `json:"block_number"`
	Buckets          []int  `json:"buckets"`
	BurnAddress      string `json:"burn_address"`
	Coeff            int    `json:"coeff"`
	ConsensusHash    string `json:"consensus_hash"`
	HistorySnapshot  bool   `json:"history_snapshot"`
	Lifetime         int    `json:"lifetime"`
	NamespaceID      string `json:"namespace_id"`
	NonalphaDiscount int    `json:"nonalpha_discount"`
	NoVowelDiscount  int    `json:"no_vowel_discount"`
	Op               string `json:"op"`
	Opcode           string `json:"opcode"`
	OpFee            int64  `json:"op_fee"`
	PreorderHash     string `json:"preorder_hash"`
	Recipient        string `json:"recipient"`
	RecipientAddress string `json:"recipient_address"`
	RevealBlock      int    `json:"reveal_block"`
	Sender           string `json:"sender"`
	SenderPubkey     string `json:"sender_pubkey"`
	Txid             string `json:"txid"`
	Version          int    `json:"version"`
	Vtxindex         int    `json:"vtxindex"`
}

NamespaceTransaction models and individual namespace transaction

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route representes an indivdual route in the Blockstack API sever

type Routes

type Routes []Route

Routes is a collection of Route

func (Routes) Routes

func (r Routes) Routes() []string

Routes returns the routes in an array

type Transaction

type Transaction struct {
	Address              string  `json:"address"`
	BlockNumber          int     `json:"block_number"`
	ConsensusHash        string  `json:"consensus_hash"`
	FirstRegistered      int     `json:"first_registered"`
	Importer             string  `json:"importer"`
	ImporterAddress      string  `json:"importer_address"`
	LastCreationOp       string  `json:"last_creation_op"`
	LastRenewed          int     `json:"last_renewed"`
	Name                 string  `json:"name"`
	BurnAddress          string  `json:"burn_address"`
	HistorySnapshot      bool    `json:"history_snapshot"`
	NameHash128          string  `json:"name_hash128"`
	NamespaceBlockNumber int     `json:"namespace_block_number"`
	NamespaceID          string  `json:"namespace_id"`
	Op                   string  `json:"op"`
	OpFee                float64 `json:"op_fee"`
	Opcode               string  `json:"opcode"`
	PreorderBlockNumber  int     `json:"preorder_block_number"`
	PreorderHash         string  `json:"preorder_hash"`
	Revoked              bool    `json:"revoked"`
	Sender               string  `json:"sender"`
	SenderPubkey         string  `json:"sender_pubkey"`
	TransferSendBlockID  int     `json:"transfer_send_block_id"`
	Txid                 string  `json:"txid"`
	ValueHash            string  `json:"value_hash"`
	Vtxindex             int     `json:"vtxindex"`
}

Transaction models a bitcoin transaction

func (Transaction) JSON

func (r Transaction) JSON() []byte

JSON proves a JSON output for ResponseWriter

type V1GetNameHistoryResponse

type V1GetNameHistoryResponse map[int][]Transaction

V1GetNameHistoryResponse holds the response for the /v1/names/{name}/history route NOTE: result of the get_name_blockchain_record rpc call

func (V1GetNameHistoryResponse) JSON

func (r V1GetNameHistoryResponse) JSON() []byte

JSON proves a JSON output for ResponseWriter

type V1GetNameNoZResponse

type V1GetNameNoZResponse struct {
	Address      string            `json:"address"`
	Blockchain   string            `json:"blockchain"`
	ExpireBlock  int               `json:"expire_block"`
	LastTxid     string            `json:"last_txid"`
	Status       string            `json:"status"`
	Zonefile     map[string]string `json:"zonefile"`
	ZonefileHash string            `json:"zonefile_hash"`
}

V1GetNameResponse is the response for the /v1/names/:name

func (V1GetNameNoZResponse) JSON

func (r V1GetNameNoZResponse) JSON() []byte

JSON proves a JSON output for ResponseWritert for ResponseWriter

type V1GetNameOpsAtHeightResponse

type V1GetNameOpsAtHeightResponse []struct {
	Address              string `json:"address"`
	BlockNumber          int    `json:"block_number"`
	ConsensusHash        string `json:"consensus_hash"`
	FirstRegistered      int    `json:"first_registered"`
	History              map[int][]Transaction
	Importer             interface{} `json:"importer"`
	ImporterAddress      interface{} `json:"importer_address"`
	KeepData             bool        `json:"keep_data"`
	LastCreationOp       string      `json:"last_creation_op"`
	LastRenewed          int         `json:"last_renewed"`
	Name                 string      `json:"name"`
	NameHash128          string      `json:"name_hash128"`
	NamespaceBlockNumber int         `json:"namespace_block_number"`
	NamespaceID          string      `json:"namespace_id"`
	Op                   string      `json:"op"`
	OpFee                int         `json:"op_fee"`
	Opcode               string      `json:"opcode"`
	PreorderBlockNumber  int         `json:"preorder_block_number"`
	PreorderHash         string      `json:"preorder_hash"`
	Recipient            string      `json:"recipient"`
	RecipientAddress     string      `json:"recipient_address"`
	Revoked              bool        `json:"revoked"`
	Sender               string      `json:"sender"`
	SenderPubkey         interface{} `json:"sender_pubkey"`
	TransferSendBlockID  int         `json:"transfer_send_block_id"`
	Txid                 string      `json:"txid"`
	ValueHash            string      `json:"value_hash"`
	Vtxindex             int         `json:"vtxindex"`
}

V1GetNameOpsAtHeightResponse holds the response for the /v1/blockchains/bitcoin/operations/:blockHeight route NOTE: List of all transactions affected at a blockHeight

func (V1GetNameOpsAtHeightResponse) JSON

JSON proves a JSON output for ResponseWriter

type V1GetNameResponse

type V1GetNameResponse struct {
	Address      string `json:"address"`
	Blockchain   string `json:"blockchain"`
	ExpireBlock  int    `json:"expire_block"`
	LastTxid     string `json:"last_txid"`
	Status       string `json:"status"`
	Zonefile     string `json:"zonefile"`
	ZonefileHash string `json:"zonefile_hash"`
}

V1GetNameResponse is the response for the /v1/names/:name

func (V1GetNameResponse) JSON

func (r V1GetNameResponse) JSON() []byte

JSON proves a JSON output for ResponseWritert for ResponseWriter

type V1GetNamesInNamespaceResponse

type V1GetNamesInNamespaceResponse []string

V1GetNamesInNamespaceResponse holds the response for the /v1/namespaces/{namespace}/names?page={page} route NOTE: result of the get_names_in_namespace rpc call

func (V1GetNamesInNamespaceResponse) JSON

JSON proves a JSON output for ResponseWriter

type V1GetNamesOwnedByAddressResponse

type V1GetNamesOwnedByAddressResponse struct {
	Names []string `json:"names"`
}

V1GetNamesOwnedByAddressResponse holds the response for the /v1/addresses/bitcoin/:address route NOTE: result of get_names_owned_by_address rpc call with a slightly different format

func (V1GetNamesOwnedByAddressResponse) JSON

JSON proves a JSON output for ResponseWriter

type V1GetNamespaceBlockchainRecordResponse

type V1GetNamespaceBlockchainRecordResponse struct {
	Address          string                       `json:"address"`
	Base             int                          `json:"base"`
	BlockNumber      int                          `json:"block_number"`
	Buckets          []int                        `json:"buckets"`
	Coeff            int                          `json:"coeff"`
	History          map[int]NamespaceTransaction `json:"history"`
	Lifetime         int                          `json:"lifetime"`
	NamespaceID      string                       `json:"namespace_id"`
	NoVowelDiscount  int                          `json:"no_vowel_discount"`
	NonalphaDiscount int                          `json:"nonalpha_discount"`
	Op               string                       `json:"op"`
	OpFee            int64                        `json:"op_fee"`
	PreorderHash     string                       `json:"preorder_hash"`
	Ready            bool                         `json:"ready"`
	ReadyBlock       int                          `json:"ready_block"`
	Recipient        string                       `json:"recipient"`
	RecipientAddress string                       `json:"recipient_address"`
	RevealBlock      int                          `json:"reveal_block"`
	Sender           string                       `json:"sender"`
	SenderPubkey     string                       `json:"sender_pubkey"`
	Txid             string                       `json:"txid"`
	Version          int                          `json:"version"`
	Vtxindex         int                          `json:"vtxindex"`
}

V1GetNamespaceBlockchainRecordResponse holds the response for the /v1/namespaces/{namespace} route NOTE: returns result of get_namespace_blockchain_record rpc call

func (V1GetNamespaceBlockchainRecordResponse) JSON

JSON proves a JSON output for ResponseWriter

type V1GetNamespacesResponse

type V1GetNamespacesResponse []string

V1GetNamespacesResponse holds the response for the /v1/namespaces route NOTE: returns result of get_all_namespaces rpc call

func (V1GetNamespacesResponse) JSON

func (r V1GetNamespacesResponse) JSON() []byte

JSON proves a JSON output for ResponseWriter

type V1GetZonefileResponse

type V1GetZonefileResponse struct {
	Zonefile string `json:"zonefile"`
}

V1GetZonefileResponse holds the response for the /v1/names/{name}/zonefile route NOTE: returns just the plaintext zonefile

func (V1GetZonefileResponse) JSON

func (r V1GetZonefileResponse) JSON() []byte

JSON proves a JSON output for ResponseWriter

type V2GetUserProfile

type V2GetUserProfile struct {
	Expired       string          `json:"expired"`
	Profile       indexer.Profile `json:"profile"`
	Verifications []struct {
		Identifier string `json:"identifier"`
		ProofURL   string `json:"proof_url"`
		Service    string `json:"service"`
		Valid      bool   `json:"valid"`
	} `json:"verifications"`
	ZoneFile indexer.Zonefile `json:"zone_file"`
}

type V2GetUserProfileResponse

type V2GetUserProfileResponse map[string]V2GetUserProfile

func (V2GetUserProfileResponse) JSON

func (r V2GetUserProfileResponse) JSON() []byte

JSON proves a JSON output for ResponseWriter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL