dexscreenerapi

package module
v0.0.0-...-9986a41 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 5 Imported by: 0

README

DexScreener Go API

A Go library for interacting with the DexScreener API. This library provides a simple and intuitive way to fetch token profiles, pair information, and search across DexScreener's supported DEXes.

Installation

go get github.com/lajosdeme/dexscreener-api

Quick Start

package main

import (
    "fmt"
    api "github.com/lajosdeme/dexscreener-api"
)

func main() {
    // Get latest token profiles
    profiles, err := api.GetLatestTokenProfiles()
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("Found %d token profiles\n", len(profiles))
}

Features

  • Full coverage of DexScreener API endpoints
  • Proper error handling
  • Easy to use interface
  • Fully type-safe responses

API Methods

Get Latest Token Profiles

Fetches the most recently updated token profiles.

profiles, err := GetLatestTokenProfiles() ([]TokenProfile, error)
Get Latest Boosted Token Profiles

Retrieves the most recently boosted token profiles.

profiles, err := GetLatestBoostedTokenProfiles() ([]BoostedTokenProfile, error)
Get Tokens with Most Active Boosts

Fetches tokens sorted by number of active boosts.

profiles, err := GetTokensWithMostActiveBoosts() ([]BoostedTokenProfile, error)
Check Orders Paid

Checks if orders are paid for a specific token on a chain.

response, err := CheckOrdersPaid(chainId string, tokenAddress string) (*OrderPaidResponse, error)
Get Pairs by Chain and Pair ID

Retrieves specific trading pairs by chain ID and pair ID.

pairs, err := GetPairsByChainAndPairId(chainId string, pairId string) (*PairsResponse, error)
Get Token Pairs

Fetches pair information for multiple token addresses (up to 30).

pairs, err := GetTokenPairs(tokenAddresses []string) (*PairsResponse, error)
Search Pairs

Searches for pairs across all supported DEXes.

pairs, err := SearchPairs(searchText string) (*PairsResponse, error)

Example Usage

Searching for Pairs
package main

import (
    "fmt"
    api "github.com/lajosdeme/dexscreener-api"
)

func main() {
    // Search for USDC pairs
    pairs, err := api.SearchPairs("SOL/USDC")
    if err != nil {
        panic(err)
    }
    
    // Print pair information
    for _, pair := range pairs.Pairs {
        fmt.Printf("Chain: %s\n", pair.ChainId)
        fmt.Printf("DEX: %s\n", pair.DexId)
        fmt.Printf("Price USD: %s\n", pair.PriceUsd)
        fmt.Printf("Liquidity USD: %.2f\n", pair.Liquidity.USD)
        fmt.Printf("---\n")
    }
}
Getting Token Pairs
package main

import (
    "fmt"
    api "github.com/lajosdeme/dexscreener-api"
)

func main() {
    // Token addresses to check
    addresses := []string{
        "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
        "7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr",
    }
    
    // Get pair information
    response, err := api.GetTokenPairs(addresses)
    if err != nil {
        panic(err)
    }
    
    // Print pair information
    for _, pair := range response.Pairs {
        fmt.Printf("Base Token: %s (%s)\n", pair.BaseToken.Name, pair.BaseToken.Symbol)
        fmt.Printf("Quote Token: %s (%s)\n", pair.QuoteToken.Name, pair.QuoteToken.Symbol)
        fmt.Printf("Price: $%s\n", pair.PriceUsd)
        fmt.Printf("---\n")
    }
}

Rate Limiting

DexScreener API has rate limits. This library does not automatically handle rate limiting, but it does provide clear error messages when you hit rate limits. It's recommended to implement your own rate limiting strategy based on your needs.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This library is licensed under the MIT License - see the LICENSE file for details.

Official Documentation

For more details about the API endpoints and responses, please refer to the official DexScreener API documentation.

Documentation

Index

Constants

View Source
const GET = "GET"

Variables

This section is empty.

Functions

This section is empty.

Types

type BoostedTokenProfile

type BoostedTokenProfile struct {
	URL          string  `json:"url"`
	ChainID      string  `json:"chainId"`
	TokenAddress string  `json:"tokenAddress"`
	Amount       float64 `json:"amount"`
	TotalAmount  float64 `json:"totalAmount"`
	Icon         string  `json:"icon"`
	Header       string  `json:"header"`
	Description  string  `json:"description"`
	Links        []Link  `json:"links"`
}

func GetLatestBoostedTokenProfiles

func GetLatestBoostedTokenProfiles() ([]BoostedTokenProfile, error)

GetLatestTokenProfiles fetches the latest token profiles

func GetTokensWithMostActiveBoosts

func GetTokensWithMostActiveBoosts() ([]BoostedTokenProfile, error)

type Boosts

type Boosts struct {
	Active int `json:"active"`
}

type Endpoint

type Endpoint string

type Info

type Info struct {
	ImageURL string    `json:"imageUrl"`
	Websites []Website `json:"websites"`
	Socials  []Social  `json:"socials"`
}
type Link struct {
	Type  string `json:"type"`
	Label string `json:"label"`
	URL   string `json:"url"`
}

type Liquidity

type Liquidity struct {
	USD   float64 `json:"usd"`
	Base  float64 `json:"base"`
	Quote float64 `json:"quote"`
}

type OrderPaidResponse

type OrderPaidResponse struct {
	Type             string `json:"type"`
	Status           string `json:"status"`
	PaymentTimestamp int    `json:"paymentTimestamp"`
}

func CheckOrdersPaid

func CheckOrdersPaid(chainId string, tokenAddress string) (*OrderPaidResponse, error)

type Pair

type Pair struct {
	ChainID       string    `json:"chainId"`
	DexID         string    `json:"dexId"`
	URL           string    `json:"url"`
	PairAddress   string    `json:"pairAddress"`
	Labels        []string  `json:"labels"`
	BaseToken     Token     `json:"baseToken"`
	QuoteToken    Token     `json:"quoteToken"`
	PriceNative   string    `json:"priceNative"`
	PriceUsd      string    `json:"priceUsd"`
	Liquidity     Liquidity `json:"liquidity"`
	FDV           float64   `json:"fdv"`
	MarketCap     float64   `json:"marketCap"`
	PairCreatedAt int64     `json:"pairCreatedAt"`
	Info          Info      `json:"info"`
	Boosts        Boosts    `json:"boosts"`
}

type PairsResponse

type PairsResponse struct {
	SchemaVersion string `json:"schemaVersion"`
	Pairs         []Pair `json:"pairs"`
}

func GetPairsByChainAndPairId

func GetPairsByChainAndPairId(chainId string, pairId string) (*PairsResponse, error)

func GetTokenPairs

func GetTokenPairs(tokenAddresses []string) (*PairsResponse, error)

GetTokenPairs fetches pair information for the given token addresses

func SearchPairs

func SearchPairs(searchText string) (*PairsResponse, error)

type Social

type Social struct {
	Platform string `json:"platform"`
	Handle   string `json:"handle"`
}

type Token

type Token struct {
	Address string `json:"address"`
	Name    string `json:"name"`
	Symbol  string `json:"symbol"`
}

type TokenProfile

type TokenProfile struct {
	URL          string `json:"url"`
	ChainID      string `json:"chainId"`
	TokenAddress string `json:"tokenAddress"`
	Icon         string `json:"icon"`
	Header       string `json:"header"`
	Description  string `json:"description"`
	Links        []Link `json:"links"`
}

func GetLatestTokenProfiles

func GetLatestTokenProfiles() ([]TokenProfile, error)

GetLatestTokenProfiles fetches the latest token profiles

type Website

type Website struct {
	URL string `json:"url"`
}

Jump to

Keyboard shortcuts

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