ephemeralproxies

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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)
	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
Details of new proxy obtained:
{
    "id": "3dd035fb5cee360fb0dc3c8cdba927fc",
    "host": "lc13e.ep-proxy.net",
    "port": 32793,
    "expires_at": "2022-04-15T20:24:40Z",
    "whitelisted_ips": [
        "219.182.31.4"
    ],
    "visibility": {
        "ip": "31.40.246.1",
        "country": "United Kingdom",
        "country_iso": "GB",
        "country_eu": true,
        "latitude": 51.5164,
        "longitude": -0.093,
        "timezone": "Europe/London",
        "asn": "",
        "asn_org": "",
        "zip_code": "EC2V",
        "region_name": "England",
        "region_code": "ENG",
        "city": "London"
    },
    "features": {
        "static": true,
        "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
Ephemeral Proxies Service Status:
{
    "availability": {
        "total": {
            "proxies": 822
        },
        "by_country": [
            {
                "country_iso": "BE",
                "proxies": 4
            },
            {
                "country_iso": "AT",
                "proxies": 12
            },
            {
                "country_iso": "PL",
                "proxies": 12
            },
            {
                "country_iso": "GB",
                "proxies": 286
            },
            {
                "country_iso": "NL",
                "proxies": 22
            },
            {
                "country_iso": "SK",
                "proxies": 9
            },
            {
                "country_iso": "IS",
                "proxies": 7
            },
            {
                "country_iso": "ES",
                "proxies": 6
            },
            {
                "country_iso": "RU",
                "proxies": 207
            },
            {
                "country_iso": "BR",
                "proxies": 113
            },
            {
                "country_iso": "EE",
                "proxies": 2
            },
            {
                "country_iso": "SA",
                "proxies": 14
            },
            {
                "country_iso": "DE",
                "proxies": 118
            },
            {
                "country_iso": "FR",
                "proxies": 10
            }
        ]
    }
}

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 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) (*Proxy, error)

NewProxy returns a new allocated proxy for the next 30 mins

func NewProxyWithOptions

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

NewProxyWithOptions returns a new allocated proxy for the next 30 mins

- 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"`
	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 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) (*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