Skip to content

joantune/rmail-shipping-REST-python-api

Repository files navigation

rmail-apiv3

This API specification details the requirements for integrating with Royal Mail API Shipping V3.

It specifically covers how the Royal Mail API Shipping V3 can be used by business customers to conduct shipping activity with Royal Mail and provides the technical information to build this integration. This specification must be used with the relevant accompanying specifications for customers wishing to interface their systems with Royal Mail services.

Royal Mail API Shipping V3 exposes a fully RESTful service that allows account customers to create shipments, produce labels, and produce documentation for all the tasks required to ship domestic items with Royal Mail.

Built on industry standards, Royal Mail API Shipping V3 provides a simple and low cost method for customers to integrate with Royal Mail, and allows them to get shipping quickly. The API offers data streaming and offline barcoding to allow customers greater flexibility when generating their labels. There are no costs to customers for using the Royal Mail API Shipping V3 services, however customers’ own development costs must be covered by the customer developing the solution. Royal Mail will not accept any responsibility for these development, implementation and testing costs. Customers should address initial enquiries regarding development of systems for these purposes to their account handler.

This API can be used in conjunction with Royal Mail Pro Shipping, a GUI based shipping platform. For more details on Royal Mail Pro Shipping, including videos on and briefs on updating/ cancelling a shipment and Manifesting please refer to http://www.royalmail.com/pro-shipping-help.

This Python package is automatically generated by the Swagger Codegen project:

  • API version: 3.0.12
  • Package version: 0.0.1
  • Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import rmail_apiv3 

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import rmail_apiv3

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import rmail_apiv3
from rmail_apiv3.rest import ApiException
from pprint import pprint

# Configure API key authorization: clientID
configuration = rmail_apiv3.Configuration()
configuration.api_key['X-IBM-Client-Id'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-IBM-Client-Id'] = 'Bearer'

# create an instance of the API class
api_instance = rmail_apiv3.AddressesApi(rmail_apiv3.ApiClient(configuration))
body = rmail_apiv3.Address() # Address | The address.
x_rmg_auth_token = 'x_rmg_auth_token_example' # str | Authorisation token required to invoke this operation. Can be retrieved by invoking the **/token** operation.

try:
    # Create Address
    api_response = api_instance.addresses_create(body, x_rmg_auth_token)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AddressesApi->addresses_create: %s\n" % e)

# Configure API key authorization: clientID
configuration = rmail_apiv3.Configuration()
configuration.api_key['X-IBM-Client-Id'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-IBM-Client-Id'] = 'Bearer'

# create an instance of the API class
api_instance = rmail_apiv3.AddressesApi(rmail_apiv3.ApiClient(configuration))
x_rmg_auth_token = 'x_rmg_auth_token_example' # str | Authorisation token required to invoke this operation. Can be retrieved by invoking the **/token** operation.
address_id = 'address_id_example' # str | Your unique Address ID of the address to delete.

try:
    # Delete Address
    api_response = api_instance.addresses_delete(x_rmg_auth_token, address_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AddressesApi->addresses_delete: %s\n" % e)

# Configure API key authorization: clientID
configuration = rmail_apiv3.Configuration()
configuration.api_key['X-IBM-Client-Id'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-IBM-Client-Id'] = 'Bearer'

# create an instance of the API class
api_instance = rmail_apiv3.AddressesApi(rmail_apiv3.ApiClient(configuration))
x_rmg_auth_token = 'x_rmg_auth_token_example' # str | Authorisation token required to invoke this operation. Can be retrieved by invoking the **/token** operation.
address_id = 'address_id_example' # str | Your unique Address ID.

try:
    # Get Address
    api_response = api_instance.addresses_get(x_rmg_auth_token, address_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AddressesApi->addresses_get: %s\n" % e)

# Configure API key authorization: clientID
configuration = rmail_apiv3.Configuration()
configuration.api_key['X-IBM-Client-Id'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-IBM-Client-Id'] = 'Bearer'

# create an instance of the API class
api_instance = rmail_apiv3.AddressesApi(rmail_apiv3.ApiClient(configuration))
x_rmg_auth_token = 'x_rmg_auth_token_example' # str | Authorisation token required to invoke this operation. Can be retrieved by invoking the **/token** operation.

try:
    # Get Addresses
    api_response = api_instance.addresses_get_all(x_rmg_auth_token)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AddressesApi->addresses_get_all: %s\n" % e)

# Configure API key authorization: clientID
configuration = rmail_apiv3.Configuration()
configuration.api_key['X-IBM-Client-Id'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-IBM-Client-Id'] = 'Bearer'

# create an instance of the API class
api_instance = rmail_apiv3.AddressesApi(rmail_apiv3.ApiClient(configuration))
body = rmail_apiv3.Address() # Address | The address with the updated details.
x_rmg_auth_token = 'x_rmg_auth_token_example' # str | Authorisation token required to invoke this operation. Can be retrieved by invoking the **/token** operation.
address_id = 'address_id_example' # str | Your unique Address ID of the address to update.

try:
    # Update address
    api_response = api_instance.addresses_update(body, x_rmg_auth_token, address_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AddressesApi->addresses_update: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to /shipping/v3

Class Method HTTP request Description
AddressesApi addresses_create POST /addresses Create Address
AddressesApi addresses_delete DELETE /addresses/{addressId} Delete Address
AddressesApi addresses_get GET /addresses/{addressId} Get Address
AddressesApi addresses_get_all GET /addresses Get Addresses
AddressesApi addresses_update PUT /addresses/{addressId} Update address
ItemsApi items_create POST /items Create Item
ItemsApi items_delete DELETE /items/{itemId} Delete Item
ItemsApi items_get GET /items/{itemId} Get Item
ItemsApi items_get_all GET /items Get Items
ItemsApi items_update PUT /items/{itemId} Update item
ManifestsApi manifests_create POST /manifests Manifest All Shipments
ManifestsApi manifests_create_by_carrier POST /manifests/bycarrier Manifest by Carrier Code(s)
ManifestsApi manifests_create_by_service POST /manifests/byservice Manifest by Service Code(s)
PackagingApi packaging_create POST /packaging Create Packaging
PackagingApi packaging_delete DELETE /packaging/{packagingId} Delete Packaging
PackagingApi packaging_get GET /packaging/{packagingId} Get Packaging
PackagingApi packaging_get_all GET /packaging Get All Packaging
PackagingApi packaging_update PUT /packaging/{packagingId} Update packaging
ShipmentsApi shipments_cancel PUT /shipments/cancel Cancel Shipments
ShipmentsApi shipments_create POST /shipments Create Shipment
ShipmentsApi shipments_defer PUT /shipments/defer Defer Shipments
ShipmentsApi shipments_hold PUT /shipments/hold Hold Shipments
ShipmentsApi shipments_print_document PUT /shipments/{shipmentId}/printDocument Print Document
ShipmentsApi shipments_print_label PUT /shipments/{shipmentId}/printLabel Print Label
ShipmentsApi shipments_release PUT /shipments/release Release Shipments
ShipmentsApi shipments_service_availability POST /shipments/serviceAvailability Service Availability
TokenApi authenticate_post POST /token Authenticates a User and provides token.

Documentation For Models

Documentation For Authorization

clientID

  • Type: API key
  • API key parameter name: X-IBM-Client-Id
  • Location: HTTP header

clientSecret

  • Type: API key
  • API key parameter name: X-IBM-Client-Secret
  • Location: HTTP header

Author

About

Royal Mail Shipping v2 and v3 REST API client for python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published