Skip to content

charly3pins/amazon-product-advertising

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amazon-product-advertising

GoDoc Build Status

Go Client Library for Amazon Product Advertising API

Usage

First of all you need to download the library in your $GOPATH using the following command:

go get -u github.com/charly3pins/amazon-product-advertising

Then, you can create a simple example.go and call the NewClient(config) constructor passing the ClientConfig with your credentials and call the ItemSearch(criteria) method with your creteria, selecting the SearchIndex and the Keywords, to search by text:

package main

import (
	"fmt"
	amazon "github.com/charly3pins/amazon-product-advertising"
)

func main() {
	criteria := amazon.Criteria{
		SearchIndex: "Books",
		Keywords:    "Clean Code",
	}
	config := amazon.ClientConfig{
		AccessKeyID:     "{YOUR_AWS_ACCESS_KEY_ID}",
		SecretAccessKey: "{YOUR_AWS_SECRET_ACCESS_KEY}",
		AssociateTag:    "collectus-21",
		Region:          "{YOUR_AWS_PRODUCT_REGION}",
		AWSEndpoint:     amazon.GetEndpoint("{YOUR_AWS_PRODUCT_REGION}"),
	}
	client := amazon.NewClient(config)
	res, err := client.ItemSearch(criteria)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Printf("%d results found\n\n", res.Items.TotalResults)
	for i, item := range res.Items.Item {
		fmt.Printf("Result: %d\nTitle: %v\nAuthor: %v\nBinding: %v\nLargeImage: %v\nURL: %v\n\n", i, item.ItemAttributes.Title, item.ItemAttributes.Author, item.ItemAttributes.Binding, item.ImageSets.ImageSet[0].LargeImage, item.DetailPageURL)
	}
}

Finally, you can execute the example created:

go run example.go

About

Go Client Library for the Amazon Product Advertising API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages