official documentation: https://yandex.ru/dev/audience/doc/concept/about-docpage/
Entity | Method | Support |
---|---|---|
Pixels | List of pixels | ✔️ |
Pixels | Create pixel | ✔️ |
Pixels | Update pixel | ✔️ |
Pixels | Remove pixel | ✔️ |
Pixels | Restore pixel | ✔️ |
Delegates | List of delegates | ✔️ |
Delegates | Create delegate | ✔️ |
Delegates | Remove delegate | ✔️ |
Accounts | List of accounts | ✔️ |
Grants | List of grants | ✔️ |
Grants | Create grant | ✔️ |
Grants | Remove grant | ✔️ |
Segments | Segments list | ✔️ |
Segments | Create "pixel" segment | ✔️ |
Segments | Create "lookalike" segment | ✔️ |
Segments | Create segment from metrika | ✔️ |
Segments | Create segment from app metrika | ✔️ |
Segments | Create geo-circle segment | ✔️ |
Segments | Create geo-polygons segment | ✔️ |
Segments | Create segment from file | ✔️ |
Segments | Create segment from csv | ✔️ |
Segments | Save uploaded segment | ✔️ |
Segments | Update segment | ✔️ |
Segments | Remove segment | ✔️ |
Segments | Reprocess segment | ✔️ |
Segments | Update coords in geo-circle segment | ❌ |
Segments | Save uploaded ClientID segment | ❌ |
Segments | Update uploaded segment | ❌ |
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)
}
}
export YANDEX_AUDIENCE_TOKEN=[YOUR TOKEN]
func main() {
//Creating audience client
client, _ := audience.NewClient(context.WithValue(context.Background(), "YANDEX_AUDIENCE_TOKEN", "[YOUR TOKEN]"))
//Your another cool code
}
- 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)
}
}
Welcome to create issue!