All Projects → ericcj → amz_sp_api

ericcj / amz_sp_api

Licence: Apache-2.0 License
AmzSpApi - Unofficial Ruby gem for the Selling Partner APIs (SP-API)

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to amz sp api

selling-partner-api-sdk
Golang toolkit for working with Amazon's Selling Partner API (SP-API)
Stars: ✭ 48 (+118.18%)
Mutual labels:  amazon, mws-api, mws, mws-sdk, sp-api, selling-partner-api, selling-partner-api-sdk
amazon-mws-api-sdk
Amazon MWS API TypeScript and Node.js Unofficial SDK
Stars: ✭ 19 (-13.64%)
Mutual labels:  mws-api, mws, amazon-mws, mws-sdk
selling-partner-sdk
Amazon Selling Partner JAVA SDK SP API
Stars: ✭ 15 (-31.82%)
Mutual labels:  amazon, mws, sp-api, selling-partner-api
sp-api-sdk
Amazon Selling Partner SPI - PHP SDKs
Stars: ✭ 34 (+54.55%)
Mutual labels:  amazon, mws, mws-sdk, selling-partner-api
Amazon-SP-API-CSharp
.Net C# library for the new Amazon Selling Partner API
Stars: ✭ 95 (+331.82%)
Mutual labels:  amazon, mws-api, selling-partner-api, selling-partner-api-sdk
mws-sdk
JavaScript SDK for Amazon Marketplace Web Services (MWS)
Stars: ✭ 23 (+4.55%)
Mutual labels:  amazon, mws, amazon-marketplace
selling-partner-api-sdk
A modularized SDK library for Amazon Selling Partner API (fully typed in TypeScript)
Stars: ✭ 13 (-40.91%)
Mutual labels:  amazon, amazon-marketplace
mws-product
A module for retrieving product information via Amazon MWS API
Stars: ✭ 40 (+81.82%)
Mutual labels:  amazon, mws
Claytondus.AmazonMWS
.NET Standard fork of Amazon MWS client
Stars: ✭ 32 (+45.45%)
Mutual labels:  amazon, amazon-mws
investigation-amazon-brands
Materials to reproduce our findings in our stories, "Amazon Puts Its Own 'Brands' First Above Better-Rated Products" and "When Amazon Takes the Buy Box, it Doesn’t Give it up"
Stars: ✭ 56 (+154.55%)
Mutual labels:  amazon
python-amazon-paapi
Amazon Product Advertising API 5.0 wrapper for Python 💰
Stars: ✭ 123 (+459.09%)
Mutual labels:  amazon
tudien
Từ điển tiếng Việt dành cho Kindle
Stars: ✭ 38 (+72.73%)
Mutual labels:  amazon
mws-orders
A Ruby interface to the Amazon MWS Orders API
Stars: ✭ 14 (-36.36%)
Mutual labels:  amazon
MoneyWellSpent
A script to summarize your money spent on Amazon
Stars: ✭ 16 (-27.27%)
Mutual labels:  amazon
go-amazon-product-advertising-api
Go Client Library for Amazon Product Advertising API
Stars: ✭ 51 (+131.82%)
Mutual labels:  amazon
ioBroker.cloud
Enable access to ioBroker from internet
Stars: ✭ 36 (+63.64%)
Mutual labels:  amazon
geeks-for-geeks-solutions
✅ My own Amazon, Microsoft and Google SDE Coding challenge Solutions (offered by GeeksForGeeks).
Stars: ✭ 246 (+1018.18%)
Mutual labels:  amazon
awesome-ecommerce
Collect and develop Open Source or Free Projects for building ecommerce platform easy and fast and free
Stars: ✭ 39 (+77.27%)
Mutual labels:  amazon
jarvis
Jarvis Home Automation
Stars: ✭ 81 (+268.18%)
Mutual labels:  amazon
delivery-finder
To help in COVID-19 situation - An automated bot to find delivery window of InstaCart and Amazon Whole Foods Market, Costco Same Day and Walmart Groceries.
Stars: ✭ 22 (+0%)
Mutual labels:  amazon

amz_sp_api

AmzSpApi - Unofficial Ruby gem for the Amazon Selling Partner API (SP-API)

This SDK is automatically generated by running Swagger Codegen on each model from https://github.com/amzn/selling-partner-api-models using the codegen.sh script.

Auto-generated documentation is nested here, but the references in https://github.com/amzn/selling-partner-api-docs are more comprehensive.

Installation

Add the gem to your Gemfile as per https://rubygems.org/gems/amz_sp_api

Getting Started

Please follow the installation procedure and then run the following code, see sp_configuration.rb for all options:

# Load the gem and specific api model you'd like to use

require 'amz_sp_api'
require 'fulfillment-outbound-api-model'

  AmzSpApi.configure do |config|
    config.refresh_token = 
    config.client_id = 
    config.client_secret = 

    # either use these:
    config.aws_access_key_id = 
    config.aws_secret_access_key = 

    # OR config.credentials_provider which is passed along to https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html, e.g.
    # require 'aws-sdk-core'
    # config.credentials_provider = Aws::STS::Client.new(
    #     region: AmzSpApi::SpConfiguration::AWS_REGION_MAP['eu'],
    #     access_key_id: ,
    #     secret_access_key: 
    #   ).assume_role(role_arn: , role_session_name: SecureRandom.uuid)

    config.region = 'eu'
    config.timeout = 20 # seconds
    # config.debugging = true

    # optional lambdas for caching LWA access token instead of requesting it each time, e.g.:
    config.save_access_token = -> (access_token_key, token) do
      Rails.cache.write("SPAPI-TOKEN-#{access_token_key}", token[:access_token], expires_in: token[:expires_in] - 60)
    end
    config.get_access_token = -> (access_token_key) { Rails.cache.read("SPAPI-TOKEN-#{access_token_key}") }
  end

  begin
    api = AmzSpApi::FulfillmentOutboundApiModel::FbaOutboundApi.new(AmzSpApi::SpApiClient.new)
    p api.list_all_fulfillment_orders.payload
  rescue AmzSpApi::ApiError => e
    puts "Exception when calling SP-API: #{e}"
  end

Documentation

This is a handy way to see all the API model class names and corresponding files you need to require for them, e.g. require 'finances-api-model' to use https://www.rubydoc.info/gems/amz_sp_api/AmzSpApi/FinancesApiModel/DefaultApi

Feeds and reports

This gem also offers encrypt/decrypt helper methods for feeds and reports, but actually using that API as per https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/feeds-api-use-case-guide requires the following calls, e.g. for feeds but reports is the same pattern:

feeds = AmzSpApi::FeedsApiModel::FeedsApi.new(AmzSpApi::SpApiClient.new)
response = feeds.create_feed_document({"contentType" => content_type})
feed_document_id = response&.payload&.dig(:feedDocumentId)
url = response.payload[:url]
encrypted = AmzSpApi.encrypt_feed(feed_content, response.payload)
# PUT to url with lowercase "content-type" header, it's already pre-signed
response = feeds.create_feed({"feedType" => feed_type, "marketplaceIds" => marketplace_ids, "inputFeedDocumentId" => feed_document_id})
feed_id = response&.payload&.dig(:feedId)
response = feeds.get_feed(feed_id)
result_feed_document_id = response&.payload&.dig(:resultFeedDocumentId) # present once it is successful
response = feeds.get_feed_document(result_feed_document_id)
url = response&.payload&.dig(:url)
# GET response&.payload&.dig(:url) into ciphertext, again it's pre-signed so no authorization needed
AmzSpApi.decrypt_and_inflate_document(ciphertext, response.payload)

Thanks

to https://github.com/patterninc/muffin_man as the basis for sp_api_client.rb

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].