ephemeralproxies

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: GPL-3.0 Imports: 7 Imported by: 1

README

Go Reference

Golang client library for Ephemeral proxies API

⚠ This library requires a valid Rapid API key to access Ephemeral Proxies API. A Rapid API key can easily be obtained on https://rapidapi.com/.

ℹ More information about Ephemeral Proxies API can be found here

Quick start

go get github.com/rpi4gx/ephemeral-proxies-go

myapp.go:

package main

import (
	"fmt"
	proxy "github.com/rpi4gx/ephemeral-proxies-go"
)

func main() {
	p, err := proxy.NewProxy("REPLACE_WITH_RAPIDAPI_KEY, ephemeralproxies.Residential)
	if err != nil {
		panic(err)
	}
	fmt.Println(p)
}

Running the examples

Clone the repo

$ git clone https://github.com/rpi4gx/ephemeral-proxies-go.git
$ cd ephemeral-proxies-go

Example 1: Pull a new proxy from the API

$ go run _examples/get_proxy.go --key=RAPIDAPI_KEY --type=datacenter
Details of new proxy obtained:
{
    "id": "61b6f0db6c79077c539aca49e9001811",
    "host": "l56ff.ep-proxy.net",
    "port": 40802,
    "expires_at": "2022-10-31T10:04:34Z",
    "whitelisted_ips": [
        "18.19.280.40"
    ],
    "visibility": {
        "ip": "185.102.113.55",
        "country": "Brazil",
        "country_iso": "BR",
        "country_eu": false,
        "latitude": -22.9072,
        "longitude": -43.1883,
        "timezone": "America/Sao_Paulo",
        "asn": "AS35830",
        "asn_org": "BTT Group Finance Ltd",
        "zip_code": "",
        "region_name": "Rio de Janeiro",
        "region_code": "RJ",
        "city": "Rio de Janeiro"
    },
    "features": {
        "static": true,
        "type": "datacenter",
        "supported_protocols": {
            "socks4": false,
            "socks5": false,
            "http": true,
            "https": true
        }
    }
}

Example 2: Get API service status

$ go run _examples/service_status.go --key=RAPIDAPI_KEY --type=residential
Ephemeral Proxies Service Status:
{
    "availability": {
        "total": {
            "proxies": 4480591
        },
        "by_country": [
            {
                "country_iso": "US",
                "proxies": 139547
            },
            {
                "country_iso": "NL",
                "proxies": 140091
            },
            {
                "country_iso": "IN",
                "proxies": 140080
            },
            {
                "country_iso": "JP",
                "proxies": 139903
            },
            {
                "country_iso": "MX",
                "proxies": 139948
            },
            {
                "country_iso": "PL",
                "proxies": 140327
            },
            {
                "country_iso": "PK",
                "proxies": 139980
            },
            {
                "country_iso": "IT",
                "proxies": 139796
            },
            {
                "country_iso": "DE",
                "proxies": 140017
            },
            {
                "country_iso": "FR",
                "proxies": 140231
            },
            {
                "country_iso": "PH",
                "proxies": 140056
            },
            {
                "country_iso": "SE",
                "proxies": 140106
            },
            {
                "country_iso": "TW",
                "proxies": 140245
            },
            {
                "country_iso": "RU",
                "proxies": 140256
            },
            {
                "country_iso": "GB",
                "proxies": 139952
            },
            {
                "country_iso": "BR",
                "proxies": 139616
            },
            {
                "country_iso": "AU",
                "proxies": 140454
            },
            {
                "country_iso": "CA",
                "proxies": 140076
            },
            {
                "country_iso": "HK",
                "proxies": 139827
            },
            {
                "country_iso": "PT",
                "proxies": 139564
            },
            {
                "country_iso": "BE",
                "proxies": 140379
            },
            {
                "country_iso": "TR",
                "proxies": 139992
            },
            {
                "country_iso": "KR",
                "proxies": 140288
            },
            {
                "country_iso": "ES",
                "proxies": 139684
            },
            {
                "country_iso": "SG",
                "proxies": 140350
            },
            {
                "country_iso": "MY",
                "proxies": 139817
            },
            {
                "country_iso": "CH",
                "proxies": 139966
            },
            {
                "country_iso": "AR",
                "proxies": 140282
            },
            {
                "country_iso": "TH",
                "proxies": 140169
            },
            {
                "country_iso": "UA",
                "proxies": 139917
            },
            {
                "country_iso": "GR",
                "proxies": 139654
            },
            {
                "country_iso": "IL",
                "proxies": 140021
            }
        ]
    }
}

Example 3: Get monthly user's balance

$ go run _examples/user_balance.go --key=RAPIDAPI_KEY
User's balance:
{
    "consumed_megabytes": 845,
    "limit_megabytes": 50000
}

Documentation

Overview

Package ephemeralproxies is a client library for https://rapidapi.com/rpi4gx/api/ephemeral-proxies API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Availability

type Availability struct {
	Total     AvailabilityTotal `json:"total"`
	Countries []Country         `json:"by_country"`
}

type AvailabilityTotal

type AvailabilityTotal struct {
	NumberOfProxies int `json:"proxies"`
}

type Balance added in v0.0.3

type Balance struct {
	ConsumedMegabytes int `json:"consumed_megabytes"`
	LimitMegabytes    int `json:"limit_megabytes"`
}

func GetUserBalance added in v0.0.3

func GetUserBalance(apiKey string, proxyType ProxyType) (*Balance, error)

GetUserBalance returns the monthly balance left for the user

func (*Balance) String added in v0.0.3

func (balance *Balance) String() string

type Country

type Country struct {
	CountryISO      string `json:"country_iso"`
	NumberOfProxies int    `json:"proxies"`
}

type Proxy

type Proxy struct {
	Id             string          `json:"id"`
	Host           string          `json:"host"`
	Port           int             `json:"port"`
	ExpirationTime time.Time       `json:"expires_at"`
	WhitelistedIps []string        `json:"whitelisted_ips"`
	Visibility     ProxyVisibility `json:"visibility"`
	Features       ProxyFeatures   `json:"features"`
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(apiKey string, proxyType ProxyType) (*Proxy, error)

NewProxy returns a new allocated proxy for the next 30 mins

func NewProxyWithOptions

func NewProxyWithOptions(apiKey string, proxyType ProxyType, countriesISO []string, extraWhitelistIp string) (*Proxy, error)

NewProxyWithOptions returns a new allocated proxy for the next 30 mins - proxyType: Type of proxy to retrieve. e.g.: `datacenter`, `residential`

- countriesISO: allows to select a preferred list of countries the proxy will be located. Example: GB,IT,ES

- extraWhitelistIp: extra IP to be allowed to connect to the proxy. Example: "90.80.70.60"

func (*Proxy) ExtendExpirationTime

func (proxy *Proxy) ExtendExpirationTime() error

ExtendExpirationTime extends the expiration time of the proxy by 30 mins.

A proxy can only be allocated by 24 hours max.

func (*Proxy) String

func (p *Proxy) String() string

type ProxyFeatures

type ProxyFeatures struct {
	IsStatic           bool                            `json:"static"`
	Type               string                          `json:"type"`
	SupportedProtocols ProxyFeaturesSupportedProtocols `json:"supported_protocols"`
}

type ProxyFeaturesSupportedProtocols

type ProxyFeaturesSupportedProtocols struct {
	Socks4 bool `json:"socks4"`
	Socks5 bool `json:"socks5"`
	Http   bool `json:"http"`
	Https  bool `json:"https"`
}

type ProxyType added in v0.0.3

type ProxyType int32
const (
	Datacenter ProxyType = iota
	Residential
)

func (ProxyType) String added in v0.0.3

func (t ProxyType) String() string

type ProxyVisibility

type ProxyVisibility struct {
	Ip                string  `json:"ip"`
	Country           string  `json:"country"`
	CountryISO        string  `json:"country_iso"`
	IsCountryInEurope bool    `json:"country_eu"`
	Latitude          float32 `json:"latitude"`
	Longitude         float32 `json:"longitude"`
	Timezone          string  `json:"timezone"`
	ASN               string  `json:"asn"`
	ASNOrganization   string  `json:"asn_org"`
	ZipCode           string  `json:"zip_code"`
	RegionName        string  `json:"region_name"`
	RegionCode        string  `json:"region_code"`
	City              string  `json:"city"`
}

type ServiceStatus

type ServiceStatus struct {
	Availability Availability `json:"availability"`
}

ServiceStatus holds the /service_status response

func GetServiceStatus

func GetServiceStatus(apiKey string, proxyType ProxyType) (*ServiceStatus, error)

GetServiceStatus returns service status of Ephemeral Proxies API

func (*ServiceStatus) String

func (ss *ServiceStatus) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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