{"id":19640146,"url":"https://github.com/gearplug/dynamics365crm-python","last_synced_at":"2025-04-28T11:31:03.514Z","repository":{"id":28685814,"uuid":"119067982","full_name":"GearPlug/dynamics365crm-python","owner":"GearPlug","description":"Dynamics365CRM API wrapper written in Python.","archived":false,"fork":false,"pushed_at":"2023-04-24T17:25:24.000Z","size":45,"stargazers_count":42,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T08:25:45.934Z","etag":null,"topics":["api","dynamics-365","library","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GearPlug.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":"2018-01-26T15:25:57.000Z","updated_at":"2025-03-17T13:27:48.000Z","dependencies_parsed_at":"2024-06-19T17:35:53.235Z","dependency_job_id":"5af7df8e-7ac1-4f7b-880e-5d0bbbb7a9cf","html_url":"https://github.com/GearPlug/dynamics365crm-python","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Fdynamics365crm-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Fdynamics365crm-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Fdynamics365crm-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Fdynamics365crm-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GearPlug","download_url":"https://codeload.github.com/GearPlug/dynamics365crm-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304787,"owners_count":21567937,"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":["api","dynamics-365","library","wrapper"],"created_at":"2024-11-11T14:04:48.867Z","updated_at":"2025-04-28T11:31:03.223Z","avatar_url":"https://github.com/GearPlug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynamics365crm-python\nDynamics365CRM API wrapper for Dynamics 365 written in Python.\nThis library works for API version: v9.0\n\n## Installing\n```\npip install dynamics365crm-python\n```\n\n## Usage\n\nThis library provides a client that is initialized with the following arguments\n\n- domain: the dynamics 365 tenant domain (yours or someone else's)\n- access_token: the retrieved token after authentication\n\nArguments for OAuth2 flow\n- client_id: your Azure AD application client id\n- client_secret: your Azure AD application client secret\n\n```python\nfrom dynamics365crm.client import Client\n\n## Normal use to make calls to the api\nclient = Client(\"https://tenant_name.crmX.dynamics.com\", access_token=\"access_token\")\n\n## OAuth2 configuration required arguments\nclient = Client(\n    \"https://tenant_name.crmX.dynamics.com\",\n    client_id=CLIENT_ID,\n    client_secret=CLIENT_SECRET,\n)\n```\n\n### OAuth2 Protocol\n#### Get authorization url\n\nThis will return a [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-python) valid authorization url, the following are required:\n\n- tenant_id: someone else's Azure AD tenant_id\n  - Ask the dynamics tenant owner to go to the [Azure Portal](portal.azure.com) and retrieve the Tenant ID from the Azure Active Directory/Overview\n  - If your app is configured as multi-tenant (for any enterprise or personal account to use) you could pass \"common\" instead od the Tenant ID\n    - However microsoft azure app configuration is a mess so the Tenant ID is preferable\n- redirect_uri: your service callback url\n- state: your unique generated state to identify the requester\n  - you could also initiate an oauth flow with msal manually with initiate_auth_code_flow method, check the [official example](https://github.com/Azure-Samples/ms-identity-python-webapp)\n\n```python\nauthorization_url = client.build_authorization_url(\"tenant_id\", \"redirect_uri\", \"state\")\n\n\u003e\u003e\u003e \"https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=XXXX\u0026response_type=code\u0026redirect_uri=https%3A%2F%your_domain/%2Fcallback%2F\u0026scope=https%3A%2F%2tenant_name.crmX.dynamics.com%2Fuser_impersonation+offline_access+openid+profile\u0026state=XXXX\u0026prompt=consent\"\n```\n\n#### Exchange the callback code for an access token\n\nTo finish the oauth protocol microsoft will redirect to your callback endpoint with a temporal code in the url query params to be exchanged for the full-fledged token (a json with the access_token, refresh_token, expires_in, etc.)\n\nAgain the (**tenant_id** or \"common\") and **redirect_uri** are required, the third argument is the code sent by microsoft\n\n```python\ntoken = client.exchange_code(\"tenant_id\", \"redirect_uri\", \"code\")\n```\n\n#### Refresh token\n\nIf the access token expires you could get a new **access_token** exchanging the long-lived **refresh_token**\n\nAgain the **tenant_id** or \"common\" is required\n\n```python\ntoken = client.refresh_access_token(\"tenant_id\", \"refresh_token\")\n```\n\n#### Set access token\n\nYou could pass the access_token in the constructor or set it with\n\n```python\nclient.set_access_token(\"access_token\")\n```\n\n## Dynamics Web API\n\n### Contacts\n- See the documentation https://docs.microsoft.com/es-es/dynamics365/customer-engagement/web-api/contact?view=dynamics-ce-odata-9\n\n#### Get Contacts\ncan receive orderby, filter, select, top, expand\n```\nlist_contacts = client.get_contacts()\n```\n\n#### Create Contact\n```\ncreate_contact = client.create_contact(firstname=\"FIRSTNAME\", lastname=\"LASTNAME\", middlename=\"MIDDLENAME\", emailaddress1=\"EMAILADDRESS\")\n```\n\n#### Delete Contact\n```\ndelete_contact = client.delete_contact('ID')\n```\n\n#### Update Contact\n```\nupdate_contact = client.update_contact('ID', firstname=\"FIRSTNAME\", lastname=\"LASTNAME\", middlename=\"MIDDLENAME\", emailaddress1=\"EMAILADDRESS\")\n```\n\n### Accounts\n- See the documentation https://docs.microsoft.com/es-es/dynamics365/customer-engagement/web-api/account?view=dynamics-ce-odata-9\n\n#### Get Accounts\ncan receive orderby, filter, select, top, expand\n```\nget_accounts = client.get_accounts()\n```\n\n#### Create Account\n```\ncreate_account = client.create_account(name=\"NAME\", websiteurl=\"WWW.WEBSITE.COM\")\n```\n\n#### Delete Account\n```\ncreate_account = client.delete_account('ID')\n```\n\n#### Update Account\n```\nupdate_account = client.update_account(id=\"ID\", name=\"NAME\")\n```\n\n### Opportunities\n- See the documentation https://docs.microsoft.com/es-es/dynamics365/customer-engagement/web-api/opportunity?view=dynamics-ce-odata-9\n\n#### Get Opportunities\ncan receive orderby, filter, select, top, expand\n```\nlist_opportunities = client.get_opportunities()\n```\n\n#### Create Opportunities\n```\ncreate_opportunities = client.create_opportunity(name=\"OPPORTUNITY NAME\")\n```\n\n#### Delete Opportunities\n```\ndelete_opportunities = client.delete_opportunity(id=\"OPPORTUNITY ID\")\n```\n\n#### Update Opportunities\n```\nupdate_opportunities = client.update_opportunity(id=\"OPPORTUNITY ID\", name=\"OPPORTUNITY NAME\", description=\"SOME DESCRIPTION\")\n```\n\n### Leads\n- See the documentation https://docs.microsoft.com/es-es/dynamics365/customer-engagement/web-api/lead?view=dynamics-ce-odata-9\n\n#### Get Leads\ncan receive orderby, filter, select, top, expand\n```\nlist_leads = client.get_leads()\n```\n\n#### Create Lead\n```\ncreate_leads = client.create_lead(fullname=\"LEAD NAME\", subject=\"LEAD SUBJECT\", mobilephone=\"123456\", websiteurl=\"WWW.WEBSITE.COM\", middlename=\"MIDDLE LEAD NAME\")\n```\n\n#### Delete Lead\n```\ndelete_leads = client.delete_lead(\"ID\")\n```\n\n#### Update Lead\n```\nupdate_leads = client.update_lead(fullname=\"LEAD NAME\", subject=\"LEAD SUBJECT\", mobilephone=\"123456\", websiteurl=\"WWW.WEBSITE.COM\", middlename=\"MIDDLE LEAD NAME\")\n```\n\n### Campaigns\n- See the documentation https://docs.microsoft.com/es-es/dynamics365/customer-engagement/web-api/campaign?view=dynamics-ce-odata-9\n\n#### Get Campaigns\ncan receive orderby, filter, select, top, expand\n```\nlist_campaigns = client.get_campaigns()\n```\n\n#### Create Campaign\n```\ncreate_campaign = client.create_campaign(name=\"CAMPAIGN NAME\", description=\"SOME DESCRIPTION\")\n```\n\n#### Delete Campaign\n```\ndelete_campaign = client.delete_campaign(id=\"ID\")\n```\n\n#### Update Campaign\n```\nupdate_campaign = client.update_campaign(id=\"ID\", name=\"CAMPAIGN NAME\", description=\"SOME DESCRIPTION\")\n```\n\n## Requirements\n- requests\n- msal\n\n## Contributing\nWe are always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.\n#### You can report any bug you find or suggest new functionality with a new [issue](https://github.com/GearPlug/dynamics365crm-python/issues).\n#### If you want to add yourself some functionality to the wrapper:\n1. Fork it ( https://github.com/GearPlug/dynamics365crm-python )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Adds my new feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearplug%2Fdynamics365crm-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgearplug%2Fdynamics365crm-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearplug%2Fdynamics365crm-python/lists"}