{"_id":"591f17b521d2ff0f00cf5a7a","category":{"_id":"591f17af21d2ff0f00cf5a48","__v":0,"project":"547cd7662eaee50800ed1089","version":"591f17ae21d2ff0f00cf5a3f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-25T10:22:16.805Z","from_sync":false,"order":8,"slug":"public-api","title":"Public API"},"parentDoc":null,"__v":0,"project":"547cd7662eaee50800ed1089","version":{"_id":"591f17ae21d2ff0f00cf5a3f","__v":1,"project":"547cd7662eaee50800ed1089","createdAt":"2017-05-19T16:05:02.775Z","releaseDate":"2017-05-19T16:05:02.775Z","categories":["591f17af21d2ff0f00cf5a40","591f17af21d2ff0f00cf5a41","591f17af21d2ff0f00cf5a42","591f17af21d2ff0f00cf5a43","591f17af21d2ff0f00cf5a44","591f17af21d2ff0f00cf5a45","591f17af21d2ff0f00cf5a46","591f17af21d2ff0f00cf5a47","591f17af21d2ff0f00cf5a48"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.1","version":"1.0.1"},"user":"573dd709b3f88f0e00dcae1f","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-14T10:30:17.053Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":54,"body":"Our open-source libraries are aimed to improve your working experience with DevMate API. At the moment there are Python and Java libraries available. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"If you've created your own library and would like to share with DevMate community, please [let us know](mailto:support:::at:::devmate.com).\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Java\"\n}\n[/block]\nDevMate API Client on Java: https://github.com/DevMate/DevMateClientJava\n\n[Getting Started](https://github.com/DevMate/DevMateClientJava#getting-started)\n\nHow to include library to your project: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<dependency>\\n    <groupId>com.devmate.pub</groupId>\\n    <artifactId>client</artifactId>\\n    <version>1.0.2</version>\\n</dependency>\\n\",\n      \"language\": \"java\",\n      \"name\": \"For Maven\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"compile group: 'com.devmate.pub', name: 'client', version: '1.0.2'\\n\",\n      \"language\": \"java\",\n      \"name\": \"For Gradle\"\n    }\n  ]\n}\n[/block]\n \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// DevMate public API token\\n// You can generate it in Settings -> API Integration\\nfinal String token = \\\"1234567890abcdef\\\";\\n\\n// Initialize client with builder\\nDevMateClient devMateClient = DevMateClientBuilder.buildDefault(token);\\n\\n// Get single customer by ID\\nint someId = 123;\\n// Data container with target object and meta data\\nData<Customer, CustomersMeta> singleCustomerData = devMateClient\\n        .customers()\\n        .getCustomerById(someId);\\n\\nCustomer singleCustomer = singleCustomerData.getData();\\n\\n// Update customer details\\nCustomer customerWithNewDetails = Customer.newBuilder(singleCustomer)\\n        .firstName(\\\"New Name\\\")\\n        .note(\\\"Something new\\\")\\n        .build();\\n\\n// Returns updated data\\nData<Customer, CustomersMeta> updatedCustomerData = devMateClient\\n        .customers()\\n        .updateCustomer(customerWithNewDetails);\\n\\n// Create new customer\\nCustomer createdCustomer = devMateClient\\n        .customers()\\n        .createCustomer(Customer.newBuilder()\\n                .email(\\\"some@email.com\\\")\\n                .firstName(\\\"Dead\\\")\\n                .lastName(\\\"Beef\\\")\\n                .build())\\n        .getData();\\n\\n// Create new license for customer\\n// License Type ID is needed, you can find it in Product -> Settings -> License Types -> ID (details field)\\nint customerId = createdCustomer.getId();\\nint licenseTypeId = 123;\\n\\nLicense license = devMateClient\\n        .customers()\\n        .createLicenseForCustomer(customerId, License.newBuilder()\\n                .licenseTypeId(licenseTypeId)\\n                .build())\\n        .getData();\\n\\n// Now you can get created license info, e.g. activation key\\nString activationKey = license.getActivationKey();\\n\\n// Get list of customers with filter parameters\\nData<List<Customer>, CustomersMeta> customersData = devMateClient\\n        .customers()\\n        .getCustomers(with()\\n                .firstNameContains(\\\"Dea\\\")\\n                .key(activationKey)\\n                .limit(20)\\n                .includeLicenses(true));\\n\\nint totalCustomers = customersData.getMeta().getTotal();\\n\\n// Reset first activation by activation key\\ndevMateClient.licenses().resetFirstActivation(activationKey);\\n\\n// Close the DevMate client\\ndevMateClient.close();\\n\",\n      \"language\": \"java\",\n      \"name\": \"Usage Example\"\n    }\n  ]\n}\n[/block]\n \n \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Python\"\n}\n[/block]\nDevMate API Client on Python: https://github.com/DevMate/DevMateClientPython\n\n[Getting Started:](https://github.com/DevMate/DevMateClientPython#installation)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pip install devmateclient\",\n      \"language\": \"text\",\n      \"name\": \"The latest stable version is always available on PyPi.\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# DevMate public API token\\n# You can generate it in Settings -> API Integration\\ntoken = '1234567890abcdef'\\n\\n# Initialize client with token\\ndm_client = devmateclient.Client(auth_token=token)\\n\\n# You still have an access to the token\\nold_token = dm_client.auth_token\\n\\n# Or you can change it in runtime\\ndm_client.auth_token = '0987654321abcdef'\\n\\n# Get single customer by ID\\ncustomer = dm_client.get_customer_by_id(123)\\n\\n# Create new customer in DevMate (email is required)\\ncustomer_details = {\\n    'email': 'some@email.com',\\n    'first_name': 'Dead',\\n    'last_name': 'Beef'\\n}\\ncreated_customer = dm_client.create_customer(customer_details)\\n\\n# Update existing customer in DevMate (id is required)\\ncustomer_update_details = dict(created_customer)\\ncustomer_update_details['company'] = 'Some Company'\\nupdated_customer = dm_client.update_customer(customer_update_details)\\n\\n# Create new license for customer (license_type_id is required)\\nnew_license = dm_client.create_license_for_customer(\\n    customer_id=123, \\n    _license={'license_type_id': 1}\\n)\\n# Now you can get created license info, e.g. activation key\\nactivation_key = new_license['activation_key']\\n\\n# Get list of customers with filter parameters and additional meta data (returns tuple)\\n# Don't set with_meta to return only customers\\ncustomers, meta = dm_client.get_customers(with_email='some@e',\\n                                          with_key=activation_key,\\n                                          with_limit=20,\\n                                          with_licenses=True,\\n                                          with_meta=True)\\n\\n# Reset first activation by activation key\\ndm_client.reset_first_activation(activation_key)\\n\\n# Close the DevMate client\\ndm_client.close()\",\n      \"language\": \"python\",\n      \"name\": \"Usage Example\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"\"\n}\n[/block]\nShould you have any questions on these libraries, you're welcome to [contact us](mailto:support@devmate.com).","excerpt":"","slug":"devmate-api-libraries","type":"basic","title":"DevMate API Libraries"}

DevMate API Libraries


Our open-source libraries are aimed to improve your working experience with DevMate API. At the moment there are Python and Java libraries available. [block:callout] { "type": "info", "body": "If you've created your own library and would like to share with DevMate community, please [let us know](mailto:support@devmate.com)." } [/block] [block:api-header] { "type": "basic", "title": "Java" } [/block] DevMate API Client on Java: https://github.com/DevMate/DevMateClientJava [Getting Started](https://github.com/DevMate/DevMateClientJava#getting-started) How to include library to your project: [block:code] { "codes": [ { "code": "<dependency>\n <groupId>com.devmate.pub</groupId>\n <artifactId>client</artifactId>\n <version>1.0.2</version>\n</dependency>\n", "language": "java", "name": "For Maven" } ] } [/block] [block:code] { "codes": [ { "code": "compile group: 'com.devmate.pub', name: 'client', version: '1.0.2'\n", "language": "java", "name": "For Gradle" } ] } [/block] [block:code] { "codes": [ { "code": "// DevMate public API token\n// You can generate it in Settings -> API Integration\nfinal String token = \"1234567890abcdef\";\n\n// Initialize client with builder\nDevMateClient devMateClient = DevMateClientBuilder.buildDefault(token);\n\n// Get single customer by ID\nint someId = 123;\n// Data container with target object and meta data\nData<Customer, CustomersMeta> singleCustomerData = devMateClient\n .customers()\n .getCustomerById(someId);\n\nCustomer singleCustomer = singleCustomerData.getData();\n\n// Update customer details\nCustomer customerWithNewDetails = Customer.newBuilder(singleCustomer)\n .firstName(\"New Name\")\n .note(\"Something new\")\n .build();\n\n// Returns updated data\nData<Customer, CustomersMeta> updatedCustomerData = devMateClient\n .customers()\n .updateCustomer(customerWithNewDetails);\n\n// Create new customer\nCustomer createdCustomer = devMateClient\n .customers()\n .createCustomer(Customer.newBuilder()\n .email(\"some@email.com\")\n .firstName(\"Dead\")\n .lastName(\"Beef\")\n .build())\n .getData();\n\n// Create new license for customer\n// License Type ID is needed, you can find it in Product -> Settings -> License Types -> ID (details field)\nint customerId = createdCustomer.getId();\nint licenseTypeId = 123;\n\nLicense license = devMateClient\n .customers()\n .createLicenseForCustomer(customerId, License.newBuilder()\n .licenseTypeId(licenseTypeId)\n .build())\n .getData();\n\n// Now you can get created license info, e.g. activation key\nString activationKey = license.getActivationKey();\n\n// Get list of customers with filter parameters\nData<List<Customer>, CustomersMeta> customersData = devMateClient\n .customers()\n .getCustomers(with()\n .firstNameContains(\"Dea\")\n .key(activationKey)\n .limit(20)\n .includeLicenses(true));\n\nint totalCustomers = customersData.getMeta().getTotal();\n\n// Reset first activation by activation key\ndevMateClient.licenses().resetFirstActivation(activationKey);\n\n// Close the DevMate client\ndevMateClient.close();\n", "language": "java", "name": "Usage Example" } ] } [/block] [block:api-header] { "type": "basic", "title": "Python" } [/block] DevMate API Client on Python: https://github.com/DevMate/DevMateClientPython [Getting Started:](https://github.com/DevMate/DevMateClientPython#installation) [block:code] { "codes": [ { "code": "pip install devmateclient", "language": "text", "name": "The latest stable version is always available on PyPi." } ] } [/block] [block:code] { "codes": [ { "code": "# DevMate public API token\n# You can generate it in Settings -> API Integration\ntoken = '1234567890abcdef'\n\n# Initialize client with token\ndm_client = devmateclient.Client(auth_token=token)\n\n# You still have an access to the token\nold_token = dm_client.auth_token\n\n# Or you can change it in runtime\ndm_client.auth_token = '0987654321abcdef'\n\n# Get single customer by ID\ncustomer = dm_client.get_customer_by_id(123)\n\n# Create new customer in DevMate (email is required)\ncustomer_details = {\n 'email': 'some@email.com',\n 'first_name': 'Dead',\n 'last_name': 'Beef'\n}\ncreated_customer = dm_client.create_customer(customer_details)\n\n# Update existing customer in DevMate (id is required)\ncustomer_update_details = dict(created_customer)\ncustomer_update_details['company'] = 'Some Company'\nupdated_customer = dm_client.update_customer(customer_update_details)\n\n# Create new license for customer (license_type_id is required)\nnew_license = dm_client.create_license_for_customer(\n customer_id=123, \n _license={'license_type_id': 1}\n)\n# Now you can get created license info, e.g. activation key\nactivation_key = new_license['activation_key']\n\n# Get list of customers with filter parameters and additional meta data (returns tuple)\n# Don't set with_meta to return only customers\ncustomers, meta = dm_client.get_customers(with_email='some@e',\n with_key=activation_key,\n with_limit=20,\n with_licenses=True,\n with_meta=True)\n\n# Reset first activation by activation key\ndm_client.reset_first_activation(activation_key)\n\n# Close the DevMate client\ndm_client.close()", "language": "python", "name": "Usage Example" } ] } [/block] [block:api-header] { "type": "basic", "title": "" } [/block] Should you have any questions on these libraries, you're welcome to [contact us](mailto:support@devmate.com).