New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/nikon72ru/yandex-audience-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/nikon72ru/yandex-audience-api

  • v1.1.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

yandex-audience-api

Yandex Audience Api with Golang
official documentation: https://yandex.ru/dev/audience/doc/concept/about-docpage/

Supported methods

EntityMethodSupport
PixelsList of pixels:heavy_check_mark:
PixelsCreate pixel:heavy_check_mark:
PixelsUpdate pixel:heavy_check_mark:
PixelsRemove pixel:heavy_check_mark:
PixelsRestore pixel:heavy_check_mark:
DelegatesList of delegates:heavy_check_mark:
DelegatesCreate delegate:heavy_check_mark:
DelegatesRemove delegate:heavy_check_mark:
AccountsList of accounts:heavy_check_mark:
GrantsList of grants:heavy_check_mark:
GrantsCreate grant:heavy_check_mark:
GrantsRemove grant:heavy_check_mark:
SegmentsSegments list:heavy_check_mark:
SegmentsCreate "pixel" segment:heavy_check_mark:
SegmentsCreate "lookalike" segment:heavy_check_mark:
SegmentsCreate segment from metrika:heavy_check_mark:
SegmentsCreate segment from app metrika:heavy_check_mark:
SegmentsCreate geo-circle segment:heavy_check_mark:
SegmentsCreate geo-polygons segment:heavy_check_mark:
SegmentsCreate segment from file:heavy_check_mark:
SegmentsCreate segment from csv:heavy_check_mark:
SegmentsSave uploaded segment:heavy_check_mark:
SegmentsUpdate segment:heavy_check_mark:
SegmentsRemove segment:heavy_check_mark:
SegmentsReprocess segment:heavy_check_mark:
SegmentsUpdate coords in geo-circle segment:x:
SegmentsSave uploaded ClientID segment:x:
SegmentsUpdate uploaded segment:x:

Quickstart

package main

import (
	"context"
	"fmt"
	"github.com/nikon72ru/yandex-audience-api/audience"
	"log"
)

func main() {
	//Creating audience client
	client, _ := audience.NewClient(context.Background())
	//Get all my segments
	allMySegments, _ := client.SegmentsList()
	_ = allMySegments

	//Create segment
	var segment = audience.CircleGeoSegment{
		BaseSegment: audience.BaseSegment{
			Name: "My new segment",
		},
		GeoSegmentType: "work",
		TimesQuantity:  20,
		PeriodLength:   30,
		Radius:         500,
		Points: []audience.Point{{
			Latitude:    65.534102,
			Longitude:   57.157753,
			Description: "random point",
		}}}
	if err := client.CreateCircleGeoSegment(&segment); err != nil {
		log.Fatal(err)
	}

	//Check ID of created segment
	fmt.Println(segment.ID)

	//Updating created segment
	segment.Name = "My updated segment"
	if err := client.UpdateSegment(segment.ID, &segment); err != nil {
		log.Fatal(err)
	}

	//Remove segment
	if err := client.RemoveSegment(segment.ID); err != nil {
		log.Fatal(err)
	}

}

Token

There are two ways to specify your token.

1. As environment variable "YANDEX_AUDIENCE_TOKEN":
export YANDEX_AUDIENCE_TOKEN=[YOUR TOKEN]
2. In context:
func main() {
	//Creating audience client
	client, _ := audience.NewClient(context.WithValue(context.Background(), "YANDEX_AUDIENCE_TOKEN", "[YOUR TOKEN]"))
	//Your another cool code
}

Segment from file

You can upload files with minimal buffering on server side

- Notice! You need to save segment after uploading
func main() {
	//Creating audience client
	client, _ := audience.NewClient(context.Background())

	var segment = audience.UploadingSegment{
		BaseSegment: audience.BaseSegment{
			Name: "segment from file",
		},
		Hashed:      false,
		ContentType: audience.Mac,
	}
	//upload file
	if err := client.CreateFileSegment(&segment, "./test-files/macs_for_uploads.csv"); err != nil {
		log.Fatal(err)
	}

	//Save uploaded segment
	if err := client.SaveUploadedSegment(&segment); err != nil {
		log.Fatal(err)
	}
}

CreateCSVSegment() and CreateReaderSegment() methods also supported


Any questions?

Welcome to create issue!

FAQs

Package last updated on 16 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc