{"id":18995419,"url":"https://github.com/innoveit/python-dhl-api","last_synced_at":"2025-04-22T13:12:29.548Z","repository":{"id":47263062,"uuid":"434535521","full_name":"innoveit/python-dhl-api","owner":"innoveit","description":"A Python module to integrate with DHL courier","archived":false,"fork":false,"pushed_at":"2024-12-11T11:37:27.000Z","size":121,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T11:40:03.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/innoveit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-03T09:19:23.000Z","updated_at":"2025-03-17T16:41:29.000Z","dependencies_parsed_at":"2024-11-08T17:43:10.301Z","dependency_job_id":null,"html_url":"https://github.com/innoveit/python-dhl-api","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"b58b91204a5c4334d85714f7f9fa53e23cabe5e9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoveit%2Fpython-dhl-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoveit%2Fpython-dhl-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoveit%2Fpython-dhl-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoveit%2Fpython-dhl-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/innoveit","download_url":"https://codeload.github.com/innoveit/python-dhl-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249268556,"owners_count":21240944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T17:30:21.144Z","updated_at":"2025-04-22T13:12:29.521Z","avatar_url":"https://github.com/innoveit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-dhl-api\n[![PyPI version](https://badge.fury.io/py/python-dhl-api.svg)](https://badge.fury.io/py/python-dhl-api)\n\nA Django module to integrate with DHL EXPRESS API (MyDHL API).\n\nDHL APIs documentation: https://developer.dhl.com/api-reference/dhl-express-mydhl-api#reference-docs-section/\n\n## Requirements\nPython 3.9+\n\n## Installation\nPython DHL API is available through pip. To easily install or upgrade it, do\n```\npip install --upgrade python-dhl-api\n```\n\n## Usage\nSet the following DHL fields in a private file.\n```\nDHL_API_KEY = ''\nDHL_API_SECRET = ''\nDHL_ACCOUNT = ''\nDHL_ACCOUNT_IMPORT = '' \nDHL_ACCOUNT_EXPORT = ''\n```\n\n## Services available\nPlease check test_validate.py to see some practical uses.\n1. Address validation\n2. Get rates and services available\n3. Create a shipment\n4. Create a pickup\n5. Upload document\n6. Check shipment\n7. Shipment status\n\n\n## Create a shipment\n```py\nservice = DHLService(api_key=Setting.DHL_API_KEY, api_secret=Setting.DHL_API_SECRET,\n                     account_number=Setting.DHL_ACCOUNT_EXPORT,\n                     test_mode=True)\n```\n\nSet one or more accounts:\n```py\naccounts = [\n    shipment.DHLAccountType(type_code=AccountType.SHIPPER, number=Setting.DHL_ACCOUNT_EXPORT),\n]\n```\nIf you want the shipper to pay also the duties then:\n\n```py\naccounts = [\n    shipment.DHLAccountType(type_code=AccountType.SHIPPER, number=Setting.DHL_ACCOUNT_EXPORT),\n    shipment.DHLAccountType(type_code=AccountType.DUTIES_TAXES, number=Setting.DHL_ACCOUNT_EXPORT),\n]\n```\n\nCreate the sender:\n```py\nsender_contact = address.DHLContactInformation(\n    company_name='Test Co.',\n    full_name='Name and surname',\n    phone='+39000000000',\n    email='matteo.munaretto@innove.it',\n    contact_type=ShipperType.BUSINESS.value\n)\nsender_address = address.DHLPostalAddress(\n    street_line1='Via Maestro Zampieri, 14',\n    postal_code='36016',\n    province_code='VI',\n    country_code='IT',\n    city_name='Thiene',\n)\nregistration_numbers = [address.DHLRegistrationNumber(\n    type_code=TypeCode.VAT.name,\n    number='42342423423',\n    issuer_country_code='IT'\n)]\n```\n\nCreate the receiver:\n```py\nreceiver_contact = address.DHLContactInformation(\n    full_name='Customer',\n    phone='+39000000000',\n    email='matteo.munaretto@innove.it',\n    contact_type=ShipperType.PRIVATE.value\n)\nreceiver_address = address.DHLPostalAddress(\n    street_line1='Rue Poncelet, 17',\n    postal_code='75017',\n    country_code='FR',\n    city_name='Paris',\n)\n```\n\nAdd the packages to ship:\n```py\npackages = [shipment.DHLProduct(\n    weight=1,\n    length=35,\n    width=28,\n    height=8\n)]\n```\n\nSet content and label output. For a list of services you are entitled to, use service get_rates.\n```py\nshipment_date = next_business_day()\nshipment_date = shipment_date.replace(hour=14, minute=0, second=0, microsecond=0)\nshipment_date = shipment_date.replace(tzinfo=ZoneInfo('Europe/Rome'))\n\nadded_service = [shipment.DHLAddedService(\n    service_code='W'\n)]\n\ncontent = shipment.DHLShipmentContent(\n    packages=packages,\n    is_custom_declarable=False,\n    description='Shipment test',\n    incoterm_code=IncotermCode.DAP.name,\n    unit_of_measurement=MeasurementUnit.METRIC.value,\n    product_code=ProductCode.EUROPE.value\n)\n\noutput = shipment.DHLShipmentOutput(\n    dpi=300,\n    encoding_format='pdf',\n    logo_file_format='png',\n    logo_file_base64=LOGO_BASE64\n)\n\ncustomer_references = ['id1', 'id2']\n```\n\nLet's ship:\n```py\ns = shipment.DHLShipment(\n    accounts=accounts,\n    sender_contact=sender_contact,\n    sender_address=sender_address,\n    sender_registration_numbers=registration_numbers,\n    receiver_contact=receiver_contact,\n    receiver_address=receiver_address,\n    ship_datetime=shipment_date,\n    added_services=added_service,\n    product_code=ProductCode.EUROPE.value,\n    content=content,\n    output_format=output,\n    customer_references=customer_references,\n    request_pickup=False\n)\n\nship = service.ship(dhl_shipment=s)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoveit%2Fpython-dhl-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnoveit%2Fpython-dhl-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoveit%2Fpython-dhl-api/lists"}