{"id":17294287,"url":"https://github.com/yallie/mdlpclient","last_synced_at":"2025-08-21T03:13:20.422Z","repository":{"id":65429480,"uuid":"254475353","full_name":"yallie/MdlpClient","owner":"yallie","description":"Честный знак. ИС «Маркировка». MDLP REST API Client","archived":false,"fork":false,"pushed_at":"2022-09-23T10:49:14.000Z","size":7204,"stargazers_count":24,"open_issues_count":5,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-01T02:02:16.885Z","etag":null,"topics":["api","mdlp","rest"],"latest_commit_sha":null,"homepage":"https://честныйзнак.рф/business/projects/medicines/documents/for_developers/","language":"C#","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/yallie.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}},"created_at":"2020-04-09T20:48:08.000Z","updated_at":"2025-04-24T13:32:30.000Z","dependencies_parsed_at":"2023-01-23T10:55:29.046Z","dependency_job_id":null,"html_url":"https://github.com/yallie/MdlpClient","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/yallie/MdlpClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yallie%2FMdlpClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yallie%2FMdlpClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yallie%2FMdlpClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yallie%2FMdlpClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yallie","download_url":"https://codeload.github.com/yallie/MdlpClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yallie%2FMdlpClient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271420150,"owners_count":24756490,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","mdlp","rest"],"created_at":"2024-10-15T11:00:40.674Z","updated_at":"2025-08-21T03:13:20.390Z","avatar_url":"https://github.com/yallie.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Честный знак. ИС «Маркировка». МДЛП\n\n[![MDLP REST API Client v3.05](https://img.shields.io/badge/честный%20знак-v3.06.1-yellowgreen)](https://честныйзнак.рф/upload/iblock/200/IS-_Markirovka_.-MDLP.-Protokol-obmena-interfeysnogo-urovnya.pdf)\n[![.NET Framework 4.62](https://img.shields.io/badge/.net-v4.62-yellow)](https://www.microsoft.com/ru-RU/download/details.aspx?id=53321)\n[![Code Coverage](https://codecov.io/gh/yallie/mdlpclient/branch/master/graph/badge.svg)](https://codecov.io/gh/yallie/mdlpclient)\n[![Unit tests](https://img.shields.io/badge/build%20passing-150%20tests-brightgreen)](https://github.com/yallie/MdlpClient/tree/master/MdlpApiClient.Tests)\n[![Code quality](https://img.shields.io/codefactor/grade/github/yallie/MdlpClient)](https://www.codefactor.io/repository/github/yallie/mdlpclient)\n[![NuGet](https://img.shields.io/nuget/v/MdlpApiClient.svg)](https://www.nuget.org/packages/MdlpApiClient)\n\n\u003cimg alt=\"MDLP API client logo\" src=\"https://raw.githubusercontent.com/yallie/MdlpClient/master/Docs/MdlpApiClientLogo.png\" width=\"50\" align=\"left\" /\u003e\n\nПротокол обмена интерфейсного уровня: [PDF](https://честныйзнак.рф/upload/iblock/200/IS-_Markirovka_.-MDLP.-Protokol-obmena-interfeysnogo-urovnya.pdf)  \nСписок реализованных методов: [TXT](https://github.com/yallie/MdlpClient/blob/master/Docs/list_of_methods.txt)\n\n# Инструкция по быстрому старту\n\n1. Прочитайте эту инструкцию, чтобы настроить окружение для работы с API: [PDF](https://честныйзнак.рф/upload/iblock/25b/Kratkaya_instruktsiya_po_bystromu_startu_dlya_izucheniya_API.pdf)  \n2. Регистрация тестовой электронной подписи УКЭП в деталях [описана тут](https://github.com/yallie/MdlpClient/blob/master/Docs/Certificates/CreateTestCertificate.md).\n\n# Как использовать REST API-клиент\n\n1. Установить провайдер КриптоПро: http://cryptopro.ru/products/cryptopro-csp\n2. Запросить в техподдержке «Честного знака» доступ к тестовому стенду API: http://api.stage.mdlp.crpt.ru\n3. Добавить в hosts строчку с IP-адресом тестового стенда:\n\n```txt\n185.196.171.27 api.stage.mdlp.crpt.ru\n``` \n\n4. Добавить в проект Nuget-пакет: https://www.nuget.org/packages/MdlpApiClient\n5. Завести себе тестовый УКЭП по этой [инструкции](https://github.com/yallie/MdlpClient/blob/master/Docs/Certificates/CreateTestCertificate.md).\n6. Проверить вызовы API по документу «Быстрый старт».\n\n## Авторизация тестовым участником\n\nКлиент для API называется `MdlpClient` (МДЛП — Мониторинг Движения Лекарственных Препаратов).\nПо умолчанию клиент работает с адресом тестовой системы.\n\nПочти все методы работы с API требуют авторизации. Для авторизации используются классы credentials.\nДля авторизации пользователя-нерезидента (логин и пароль) используется `NonResidentCredentials`.\nДля резидента (авторизация с помощью сертификата ГОСТ) — соответственно, `ResidentCredentials`.\n\nПри запуске конструктора клиент просто сохраняет указанные credentials, но не устанавливает соединение.\nУстановка соединения и авторизация происходит при вызове любого метода API:\n\n```c#\n// клиент пока никуда не коннектится\nvar client = new MdlpClient(credentials: new NonResidentCredentials\n{\n    ClientID = \"01db16f2-9a4e-4d9f-b5e8-c68f12566fd5\",\n    ClientSecret = \"9199fe04-42c3-4e81-83b5-120eb5f129f2\",\n    UserID = \"starter_resident_1\",\n    Password = \"password\"\n});\n\n// тут будет установлено соединение и выполнен запрошенный метод API:\nvar doc = client.GetDocumentMetadata(\"60786bb4-fcb5-4587-b703-d0147e3f9d1c\");\nConsole.WriteLine($\"Код документа: {doc.DocumentID}\");\nConsole.WriteLine($\"Код запроса: {doc.RequestID}\");\n```\n\nЧтобы трассировать все http-запросы и ответы, можно установить свойство `Tracer`:\n\n```c#\nclient.Tracer = Console.WriteLine;\n```\n\u003cdetails\u003e\n  \u003csummary\u003eПри выполнении вышеприведенного кода трассировка выглядит так:\u003c/summary\u003e\n    \n```c\n// Authenticate\n-\u003e POST http://api.stage.mdlp.crpt.ru/api/v1/auth\nheaders: {\n  X-ApiMethodName = Authenticate\n  Accept = application/json, text/json, text/x-json, text/javascript, application/xml, text/xml\n  Content-type = application/json\n}\nbody: {\n  \"client_id\": \"01db16f2-9a4e-4d9f-b5e8-c68f12566fd5\",\n  \"client_secret\": \"9199fe04-42c3-4e81-83b5-120eb5f129f2\",\n  \"user_id\": \"starter_resident_1\",\n  \"auth_type\": \"PASSWORD\"\n}\n\n\u003c- OK 200 (OK) http://api.stage.mdlp.crpt.ru/api/v1/auth\ntimings: {\n  started: 2020-04-22 20:22:12\n  elapsed: 00:00:00.1971392\n}\nheaders: {\n  Connection = keep-alive\n  X-XSS-Protection = 1; mode=block\n  Pragma = no-cache\n  X-Frame-Options = DENY\n  X-Content-Type-Options = nosniff\n  X-Application-Context = authentication-service-frontend:8095\n  Strict-Transport-Security = max-age=15768000\n  Content-Length = 47\n  Cache-Control = no-cache, no-store, max-age=0, must-revalidate\n  Content-Type = application/json;charset=UTF-8\n  Date = Wed, 22 Apr 2020 17:22:12 GMT\n  Expires = 0\n  Server = nginx/1.14.0\n}\nbody: {\n  \"code\": \"7c08d5f3-4a0c-4a71-b123-638533b4612c\"\n}\n\n// GetToken\n-\u003e POST http://api.stage.mdlp.crpt.ru/api/v1/token\nheaders: {\n  X-ApiMethodName = GetToken\n  Accept = application/json, text/json, text/x-json, text/javascript, application/xml, text/xml\n  Content-type = application/json\n}\nbody: {\n  \"code\": \"7c08d5f3-4a0c-4a71-b123-638533b4612c\",\n  \"password\": \"password\"\n}\n\n\u003c- OK 200 (OK) http://api.stage.mdlp.crpt.ru/api/v1/token\ntimings: {\n  started: 2020-04-22 20:22:12\n  elapsed: 00:00:00.2673376\n}\nheaders: {\n  Connection = keep-alive\n  X-XSS-Protection = 1; mode=block\n  Pragma = no-cache\n  X-Frame-Options = DENY\n  X-Content-Type-Options = nosniff\n  X-Application-Context = authentication-service-frontend:8095\n  Strict-Transport-Security = max-age=15768000\n  Content-Length = 63\n  Cache-Control = no-cache, no-store, max-age=0, must-revalidate\n  Content-Type = application/json;charset=UTF-8\n  Date = Wed, 22 Apr 2020 17:22:13 GMT\n  Expires = 0\n  Server = nginx/1.14.0\n}\nbody: {\n  \"token\": \"9189625f-2bea-4cf9-a36d-2c827b08d276\",\n  \"life_time\": 30\n}\n\n// GetDocumentMetadata\n-\u003e GET http://api.stage.mdlp.crpt.ru/api/v1/documents/60786bb4-fcb5-4587-b703-d0147e3f9d1c\nheaders: {\n  X-ApiMethodName = GetDocumentMetadata\n  Authorization = token 9189625f-2bea-4cf9-a36d-2c827b08d276\n  Accept = application/json, text/json, text/x-json, text/javascript, application/xml, text/xml\n}\n\n\u003c- OK 200 (OK) http://api.stage.mdlp.crpt.ru/api/v1/documents/60786bb4-fcb5-4587-b703-d0147e3f9d1c\ntimings: {\n  started: 2020-04-22 20:22:12\n  elapsed: 00:00:00.5673959\n}\nheaders: {\n  Transfer-Encoding = chunked\n  Connection = keep-alive\n  X-Application-Context = mdlp-api-document-front\n  X-Content-Type-Options = nosniff\n  X-XSS-Protection = 1; mode=block\n  Pragma = no-cache\n  X-Frame-Options = DENY\n  Strict-Transport-Security = max-age=15768000\n  Cache-Control = no-cache, no-store, max-age=0, must-revalidate\n  Content-Type = application/json;charset=UTF-8\n  Date = Wed, 22 Apr 2020 17:22:13 GMT\n  Expires = 0\n  Server = nginx/1.14.0\n}\nbody: {\n  \"request_id\": \"528700e0-f967-4ddb-995d-5c6c7b73bcc9\",\n  \"document_id\": \"60786bb4-fcb5-4587-b703-d0147e3f9d1c\",\n  \"date\": \"2020-04-07 07:55:33\",\n  \"processed_date\": \"2020-04-07 07:55:33\",\n  \"sender\": \"00000000100928\",\n  \"receiver\": \"00000000100930\",\n  \"sys_id\": \"9dedee17-e43a-47f1-910e-3a88ff6bc81b\",\n  \"doc_type\": 607,\n  \"doc_status\": \"PROCESSED_DOCUMENT\",\n  \"file_uploadtype\": 2,\n  \"sender_sys_id\": \"6f6fa779-b637-4234-9117-8ac4c1a9a81c\",\n  \"version\": \"1.34\"\n}\n```\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyallie%2Fmdlpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyallie%2Fmdlpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyallie%2Fmdlpclient/lists"}