Welcome to Shopify Requests’ documentation!¶
The ShopifyRequests library is a wrapper around the python requests library. Its main purpose is to remove the boiler plate code needed to do basic API calls to Shopify.
User’s Guide¶
The RestClient
is meant to be as simple as using the requests library.
All the http verbs needed for REST calls are available.
GET
PUT
POST
PATCH
DELETE
OAuth token example:
from shopify_requests import RestClient
client = RestClient(
'foo.myshopify.com',
access_token='abc123',
)
response = client.get('shop.json')
Private app example:
from shopify_requests import RestClient
client = RestClient(
'foo.myshopify.com',
username='1234',
password='asdf',
)
response = client.get('shop.json')
By default the client also has safe retries enabled to help with network issues. If a request fails to send data to Shopify, it will be retried a 3 times before returning the failure response. This can be configured with the connect_retries parameter.
from shopify_requests import RestClient
client = RestClient(
'foo.myshopify.com',
access_token='abc123',
connect_retries=5,
)
response = client.get('shop.json')
Reusing the client has the added benefit of reusing the http session once the connection is established. This means that subsequent calls will not have to do the SSL handshake.
API Docs¶
shopify_requests¶
shopify_requests package¶
Submodules¶
shopify_requests.errors module¶
-
exception
shopify_requests.errors.
ResourceDeprecationWarning
¶ Bases:
shopify_requests.errors.ShopifyRequestsWarning
,DeprecationWarning
Shopify has deprecated the resource or property.
-
exception
shopify_requests.errors.
ShopifyRequestsWarning
¶ Bases:
Warning
Base warning for ShopifyRequests.
shopify_requests.rest_client module¶
-
class
shopify_requests.rest_client.
RestClient
(myshopify_domain, access_token=None, username=None, password=None, connect_retries=None, backoff_factor=None, max_limit_retries=None, limit_backoff_factor=None, version=None)¶ Bases:
object
Create a session client for this Shopify store.
- Note
Only access_token or (username and password) are required
- urllib3 documents backoff_factor as
{backoff factor} * (2 ** ({number of total retries} - 1))
- Parameters
myshopify_domain – foobar.myshopify.com
access_token – OAuth token from a pubilc app
username – Username for private app
password – Password for private app
connect_retries –
[default: 3]
how many connection-related errors to retry onbackoff_factor –
[default: 0.5]
how quickly to backoff for safe retriesmax_limit_retries –
[default: 0]
how many retries to do when rate limitedlimit_backoff_factor –
[default: 0.5]
same as backoff_factor but for rate limitedversion –
[default: unstable]
the Shopify API version to use
-
calls_remaining
()¶ Return the number of API calls remaining.
- Return type
int
- See also
-
calls_used
()¶ Return the number of API calls used.
- Return type
int
- See also
-
close
()¶ Close the session.
- See also
-
delete
(url, **kwargs)¶ Send a DELETE request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
get
(url, **kwargs)¶ Send a GET request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
max_available
()¶ Return the bucket size for the token.
- Return type
int
- See also
-
patch
(url, **kwargs)¶ Send a PATCH request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
post
(url, **kwargs)¶ Send a POST request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
put
(url, **kwargs)¶ Send a PUT request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
Module contents¶
-
class
shopify_requests.
RestClient
(myshopify_domain, access_token=None, username=None, password=None, connect_retries=None, backoff_factor=None, max_limit_retries=None, limit_backoff_factor=None, version=None)¶ Bases:
object
Create a session client for this Shopify store.
- Note
Only access_token or (username and password) are required
- urllib3 documents backoff_factor as
{backoff factor} * (2 ** ({number of total retries} - 1))
- Parameters
myshopify_domain – foobar.myshopify.com
access_token – OAuth token from a pubilc app
username – Username for private app
password – Password for private app
connect_retries –
[default: 3]
how many connection-related errors to retry onbackoff_factor –
[default: 0.5]
how quickly to backoff for safe retriesmax_limit_retries –
[default: 0]
how many retries to do when rate limitedlimit_backoff_factor –
[default: 0.5]
same as backoff_factor but for rate limitedversion –
[default: unstable]
the Shopify API version to use
-
calls_remaining
()¶ Return the number of API calls remaining.
- Return type
int
- See also
-
calls_used
()¶ Return the number of API calls used.
- Return type
int
- See also
-
close
()¶ Close the session.
- See also
-
delete
(url, **kwargs)¶ Send a DELETE request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
get
(url, **kwargs)¶ Send a GET request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
max_available
()¶ Return the bucket size for the token.
- Return type
int
- See also
-
patch
(url, **kwargs)¶ Send a PATCH request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
post
(url, **kwargs)¶ Send a POST request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also
-
put
(url, **kwargs)¶ Send a PUT request.
- Parameters
url – URL for the new Request object.
**kwargs – Optional arguments that session takes.
- Return type
- See also