{"id":22654321,"url":"https://github.com/sysix/lexoffice-php-api","last_synced_at":"2025-04-14T21:39:18.430Z","repository":{"id":37535995,"uuid":"268563629","full_name":"Sysix/lexoffice-php-api","owner":"Sysix","description":"Simple API Integration for lexoffice","archived":false,"fork":false,"pushed_at":"2025-02-14T11:38:39.000Z","size":418,"stargazers_count":23,"open_issues_count":0,"forks_count":9,"subscribers_count":5,"default_branch":"development","last_synced_at":"2025-04-14T21:38:52.627Z","etag":null,"topics":["api","api-client","lexoffice","php","psr-18"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/Sysix.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":"2020-06-01T15:43:00.000Z","updated_at":"2025-02-14T11:38:43.000Z","dependencies_parsed_at":"2023-12-31T19:29:03.716Z","dependency_job_id":"5ad80ea1-3705-4ba2-a73a-651561179715","html_url":"https://github.com/Sysix/lexoffice-php-api","commit_stats":{"total_commits":127,"total_committers":7,"mean_commits":"18.142857142857142","dds":"0.40944881889763785","last_synced_commit":"5a730d27f5530449842852d81dc8ec5fad81bbd1"},"previous_names":["sysix/lexoffice-php-api"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sysix%2Flexoffice-php-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sysix%2Flexoffice-php-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sysix%2Flexoffice-php-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sysix%2Flexoffice-php-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sysix","download_url":"https://codeload.github.com/Sysix/lexoffice-php-api/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248965770,"owners_count":21190672,"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","api-client","lexoffice","php","psr-18"],"created_at":"2024-12-09T09:49:27.236Z","updated_at":"2025-04-14T21:39:18.392Z","avatar_url":"https://github.com/Sysix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lexoffice PHP API\n\n![tests](https://github.com/sysix/lexoffice-php-api/workflows/tests/badge.svg)\n![test coverage](https://raw.githubusercontent.com/sysix/lexoffice-php-api/badges/.badges/development/coverage.svg)\n[![type coverage](https://shepherd.dev/github/Sysix/lexoffice-php-api/coverage.svg)](https://shepherd.dev/github/Sysix/lexoffice-php-api)\n[![Latest Stable Version](https://poser.pugx.org/sysix/lex-office-api/v)](//packagist.org/packages/sysix/lex-office-api)\n[![License](https://poser.pugx.org/sysix/lex-office-api/license)](//packagist.org/packages/sysix/lex-office-api)\n\n## Requirements\n\nPHP: \u003e= 8.1  \nExtensions: \n- [Composer](https://getcomposer.org/)\n- [PHP-JSON](https://www.php.net/manual/en/book.json.php)\n- [PSR-18 HTTP-Client](https://packagist.org/providers/psr/http-client-implementation)\n\n## Install\n\ncomposer:  \n`composer require sysix/lex-office-api`\n\n## Usage\n\nSearch for the [official API Documentation](https://developers.lexoffice.io/docs/).  \nYou need an [API Key](https://app.lexoffice.de/addons/public-api) for that.\n\n### Basic\n```php\n// store keys in .env file\n$apiKey = getenv('LEXOFFICE_API_KEY'); \n\n// in this example we are using guzzlehttp/guzzle package, it can be any PSR-18 HTTP Client \n// see: https://packagist.org/providers/psr/http-client-implementation\n$httpClient = \\GuzzleHttp\\Client();\n$api = new \\Sysix\\LexOffice\\Api($apiKey, $httpClient);\n```\n\n### Optimize your HTTP Client\n\nThis library only prepares the `\\Psr\\Http\\Message\\RequestInterface` for the HTTP Client and returns its Response.  \nThere are almost no error checks, no caching and no rate limiting. Your PSR-18 HTTP Client should come with a way to deal with it.  \n\nHere is a example with `guzzlehttp/guzzle` , `kevinrob/guzzle-cache-middleware` and `spatie/guzzle-rate-limiter-middleware`:\n\n```php\n$apiKey = getenv('LEXOFFICE_API_KEY'); \n\n$stack = \\GuzzleHttp\\HandlerStack::create();\n$stack-\u003epush(new \\Kevinrob\\GuzzleCache\\CacheMiddleware(), 'cache');\n$stack-\u003epush(\\Spatie\\GuzzleRateLimiterMiddleware\\RateLimiterMiddleware::perSecond(2));\n\n$httpClient = \\GuzzleHttp\\Client(['handler' =\u003e $stack]);\n$api = new \\Sysix\\LexOffice\\Api($apiKey, $httpClient);\n```\n\n## Endpoints\n\n\n### Article Endpoint\n```php\n\n/** @var \\Sysix\\LexOffice\\Api $api */\n$client = $api-\u003earticle();\n\n// filters\n$client-\u003esize = 100;\n$client-\u003esortDirection = 'DESC';\n\n$client-\u003earticleNumber = 'LXW-BUHA-2024-001';\n$client-\u003egtin = '9783648170632';\n$client-\u003etype = 'PRODUCT';\n\n\n// get a page\n$response = $client-\u003egetPage(0);    \n\n// other methods\n$response = $client-\u003eget($entityId);\n$response = $client-\u003ecreate($data);\n$response = $client-\u003eupdate($entityId, $data);\n$response = $client-\u003edelete($entityId);\n\n```\n\n### Contact Endpoint\n```php\n\n$client = $api-\u003econtact();\n\n// filters\n$client-\u003esize = 100;\n$client-\u003eemail = 'john.doe@example.com';\n$client-\u003ename = 'John Doe';\n$client-\u003enumber = 123456;\n$client-\u003ecustomer = true;\n$client-\u003evendor = false;\n\n// get a page\n$response = $client-\u003egetPage(0);    \n\n// other methods\n$response = $client-\u003eget($entityId);\n$response = $client-\u003ecreate($data);\n$response = $client-\u003eupdate($entityId, $data);\n\n```\n\n### Country Endpoint\n```php\n$response = $api-\u003ecountry()-\u003egetAll();\n```\n\n### Credit Notes Endpoint\n```php\n$voucherList = $api-\u003ecreditNote()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003ecreditNote()-\u003eget($entityId);\n$response = $api-\u003ecreditNote()-\u003ecreate($data);\n$response = $api-\u003ecreditNote()-\u003ecreate($data, true); // finalized\n$response = $api-\u003ecreditNote()-\u003epursue($precedingSalesVoucherId, $data);\n$response = $api-\u003ecreditNote()-\u003epursue($precedingSalesVoucherId, $data, true); // finalized\n$response = $api-\u003ecreditNote()-\u003edocument($entityId); // get document ID\n$response = $api-\u003ecreditNote()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003ecreditNote()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Deliverys Notes Endpoint\n```php\n$voucherList = $api-\u003edeliveryNote()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003edeliveryNote()-\u003eget($entityId);\n$response = $api-\u003edeliveryNote()-\u003ecreate($data);\n$response = $api-\u003edeliveryNote()-\u003epursue($precedingSalesVoucherId, $data);\n$response = $api-\u003edeliveryNote()-\u003edocument($entityId); // get document ID\n$response = $api-\u003edeliveryNote()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003edeliveryNote()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Down Payment Invoices Endpoint\n```php\n$voucherList = $api-\u003edownPaymentInvoice()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003edownPaymentInvoice()-\u003eget($entityId);\n$response = $api-\u003edownPaymentInvoice()-\u003ecreate($data);\n$response = $api-\u003edownPaymentInvoice()-\u003edocument($entityId); // get document ID\n$response = $api-\u003edownPaymentInvoice()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003edownPaymentInvoice()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Dunnings Endpoint\n```php\n$response = $api-\u003edunning()-\u003eget($entityId);\n$response = $api-\u003edunning()-\u003epursue($precedingSalesVoucherId, $data);\n$response = $api-\u003edunning()-\u003edocument($entityId); // get document ID\n$response = $api-\u003edunning()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003edunning()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Event Subscriptions Endpooint\n```php\n$response = $api-\u003eevent()-\u003eget($entityId);\n$response = $api-\u003eevent()-\u003ecreate($data);\n$response = $api-\u003eevent()-\u003edelete($entityId);\n$response = $api-\u003eevent()-\u003egetAll();\n```\n\n### File Endpoint\n```php\n$response = $api-\u003efile()-\u003eupload($filePath, $voucherType);\n$response = $api-\u003efile()-\u003eget($entityId); // accept every file\n$response = $api-\u003efile()-\u003eget($entityId, 'image/*'); // accept only images\n$response = $api-\u003efile()-\u003eget($entityId, 'application/xml'); // get XRechung XML File (if possible)\n```\n\n### Invoices Endpoint\n```php\n$voucherList = $api-\u003einvoice()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003einvoice()-\u003eget($entityId);\n$response = $api-\u003einvoice()-\u003ecreate($data);\n$response = $api-\u003einvoice()-\u003ecreate($data, true); // finalized\n$response = $api-\u003einvoice()-\u003epursue($precedingSalesVoucherId, $data);\n$response = $api-\u003einvoice()-\u003epursue($precedingSalesVoucherId, $data, true); // finalized\n$response = $api-\u003einvoice()-\u003edocument($entityId); // get document ID\n$response = $api-\u003einvoice()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003einvoice()-\u003edocument($entityId, true, 'image/*'); // accept only images\n$response = $api-\u003einvoice()-\u003edocument($entityId, true, 'application/xml'); // get XRechung XML File (if possible)\n```\n\n### Order Confirmation Endpoint\n```php\n$voucherList = $api-\u003eorderConfirmation()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003eorderConfirmation()-\u003eget($entityId);\n$response = $api-\u003eorderConfirmation()-\u003ecreate($data);\n$response = $api-\u003eorderConfirmation()-\u003epursue($precedingSalesVoucherId, $data);\n$response = $api-\u003eorderConfirmation()-\u003edocument($entityId); // get document ID\n$response = $api-\u003eorderConfirmation()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003eorderConfirmation()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Payment  Endpoint\n```php\n$response = $api-\u003epayment()-\u003eget($entityId);\n```\n\n### Payment Conditions Endpoint\n```php\n$response = $api-\u003epaymentCondition()-\u003egetAll();\n```\n\n### Posting Categories Endpoint\n```php\n$response = $api-\u003epostingCategory()-\u003egetAll();\n```\n\n### Print Layouts Endpoint\n```php\n$response = $api-\u003eprintLayout()-\u003egetAll();\n```\n\n### Profile Endpoint\n```php\n$response = $api-\u003eprofile()-\u003eget();\n```\n\n### Quotation Endpoint\n```php\n$voucherList = $api-\u003equotation()-\u003egetVoucherListClient(); // see VoucherlistClient Documentation\n$response = $api-\u003equotation()-\u003eget($entityId);\n$response = $api-\u003equotation()-\u003ecreate($data);\n$response = $api-\u003equotation()-\u003ecreate($data, true); // finalized\n$response = $api-\u003equotation()-\u003edocument($entityId); // get document ID\n$response = $api-\u003equotation()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003equotation()-\u003edocument($entityId, true, 'image/*'); // accept only images\n```\n\n### Recurring Templates Endpoint\n```php\n\n$client = $api-\u003erecurringTemplate();\n\n// filters\n$client-\u003esize = 100;\n$client-\u003esortDirection = 'DESC';\n$client-\u003esortColumn = 'updatedDate';\n\n// get a page\n$response = $client-\u003egetPage(0);\n\n// other methods\n$response = $api-\u003erecurringTemplate()-\u003eget($entityId);\n```\n\n### Voucher Endpoint\n```php\n$response = $api-\u003evoucher()-\u003eget($entityId);\n$response = $api-\u003evoucher()-\u003ecreate($data);\n$response = $api-\u003evoucher()-\u003eupdate($entityId, $data);\n$response = $api-\u003evoucher()-\u003edocument($entityId); // get document ID\n$response = $api-\u003evoucher()-\u003edocument($entityId, true); // get file content\n$response = $api-\u003evoucher()-\u003edocument($entityId, true, 'image/*'); // accept only images\n$response = $api-\u003evoucher()-\u003edocument($entityId, true, 'application/xml'); // get XRechung XML File (if possible)\n$response = $api-\u003evoucher()-\u003eupload($entitiyId, $filepath);\n```\n\n### Voucherlist Endpoint\n```php\n$client = $api-\u003evoucherlist();\n\n$client-\u003esize = 100;\n$client-\u003esortDirection = 'DESC';\n$client-\u003esortColumn = 'voucherNumber';\n\n// filters required\n$client-\u003etypes = [\n    'salesinvoice',\n    'salescreditnote',\n    'purchaseinvoice',\n    'purchasecreditnote',\n    'invoice',\n    'downpaymentinvoice',\n    'creditnote',\n    'orderconfirmation',\n    'quotation'\n];\n$client-\u003estatuses = [\n    'draft',\n    'open',\n    'paid',\n    'paidoff',\n    'voided',\n    //'overdue', overdue can only be fetched alone\n    'accepted',\n    'rejected'\n];\n\n// filters optional\n$client-\u003earchived = true;\n$client-\u003econtactId = 'some-uuid-string';\n$client-\u003evoucherDateFrom = new \\DateTime('2023-12-01');\n$client-\u003evoucherDateTo = new \\DateTime('2023-12-01');\n$client-\u003ecreatedDateFrom = new \\DateTime('2023-12-01');;\n$client-\u003ecreatedDateTo = new \\DateTime('2023-12-01');\n$client-\u003eupdatedDateFrom = new \\DateTime('2023-12-01');\n$client-\u003eupdatedDateTo = new \\DateTime('2023-12-01');\n\n// get a page\n$response = $client-\u003egetPage(0);\n```\n\n## Utils \n\n### get JSON from Success and Error Response\n\n```php\n// can be possible null because the response body can be empty\n$json = \\Sysix\\LexOffice\\Utils::getJsonFromResponse($response); // as object\n$json = \\Sysix\\LexOffice\\Utils::getJsonFromResponse($response, true); // as associative array\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysix%2Flexoffice-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysix%2Flexoffice-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysix%2Flexoffice-php-api/lists"}