{"id":21424609,"url":"https://github.com/ghentcdh/melkschaap","last_synced_at":"2025-10-06T13:14:09.873Z","repository":{"id":230193711,"uuid":"777673519","full_name":"GhentCDH/Melkschaap","owner":"GhentCDH","description":"A python library for Nodegoat","archived":false,"fork":false,"pushed_at":"2024-11-06T09:32:49.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-23T07:14:39.271Z","etag":null,"topics":["nodegoat"],"latest_commit_sha":null,"homepage":"","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/GhentCDH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-26T09:54:36.000Z","updated_at":"2024-11-06T09:34:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"ffed55b8-b526-4fa2-9cb0-b6eb2b33bd2f","html_url":"https://github.com/GhentCDH/Melkschaap","commit_stats":null,"previous_names":["ghentcdh/llama"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhentCDH%2FMelkschaap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhentCDH%2FMelkschaap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhentCDH%2FMelkschaap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhentCDH%2FMelkschaap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GhentCDH","download_url":"https://codeload.github.com/GhentCDH/Melkschaap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933376,"owners_count":20370988,"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":["nodegoat"],"created_at":"2024-11-22T21:23:22.105Z","updated_at":"2025-10-06T13:14:04.823Z","avatar_url":"https://github.com/GhentCDH.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Melkschaap\n\nA python library for [Nodegoat](https://nodegoat.net). This library eats models and objects from the Nodegoat API and spits readable json data.\n\n## Features\n\n- model and object API requests\n- cached classification requests\n- json formatter for Nodegoat object responses\n    - convert field description ids to names\n    - cast field values to associated field type\n    - traverse references to classifications, objects and media\n\n## Installation\n\nFirst install the dependencies with a command similar to the command below. Here the installation is done for the user and not global. It uses `pip` and not `pip3` which may be the same on your system.\n\n```pip install --user -r requirements.txt```\n\n\n\n## API\n\n```python\nfrom melkschaap import NodegoatAPI\n\nnodegoat_api = NodegoatAPI('https://api.nodegoat.net', \n                  'my_very_secret_api_token',\n                  project_id=1701)\n\n## raw api requests (uncached)\n# get project model\nmodel_response = nodegoat_api.model_request()\n# get type specific model\nmodel_response = nodegoat_api.model_request(type_id=1234)\n# get objects of type 1234\ndata_response = nodegoat_api.object_request(type_id=1234)\n# get specific object(s)\ndata_response = nodegoat_api.object_request(object_id=456789)\n\n## cached data/type requests\nobject_description = nodegoat_api.get_object_type(type_id=1234)\n\nobjects = nodegoat_api.get_object(object_id=56789) # single object\nobjects = nodegoat_api.get_object(type_id=1234) # all results for type 1234\n```\n\n## Formatter\n\nThe Nodegoat API returns raw data in a format that reflects the internal database structure, making the data hard to read and process. Furthermore, Nodegoat outputs all primitive type values (int, float, bool) as strings, requiring extra processing to cast the values to their associated type.\n\nExample: the string value \"1\" can be the string value \"1\", a boolean True, the integer number 1 or the floating point number $`10^{-10}`$.\n\nThe formatter can fix these problemes and convert the output to a more readable json object. The formatter can also traverse references to other data (objects, classifications or media). Some options can be configured using an optional Mapper object.\n\n### Usage\n\n```python\nfrom melkschaap import NodegoatAPI, ObjectFormatter, MapperDefaults, ObjectMapper, FieldMapper, TypeMapper\n\nmapper = ModelMapper(\n    defaults=MapperDefaults(traverse_classification=True, traverse_type=False, cast_values=True),\n    types={\n        1286: ObjectMapper(\n            fields={\n                4732: FieldMapper(traverse=True),\n                5040: FieldMapper(traverse=True),\n            },\n        ),\n        1292: ObjectMapper(\n            exclude_fields={'sequence'},\n        ),\n    }\n)\nformatter = ObjectFormatter(api=nodegoat_api, mapper=mapper)\n\nobject = nodegoat_api.get_object(object_id=456789)\noutput = formatter.format(object)\n```\n\n### Example\n\n**Nodegoat output**\n\n```json\n{\n    \"2484072\": {\n        \"object\": {\n            \"type_id\": 1286,\n            \"nodegoat_id\": \"ngGN7K27sINasHdHzGBKquNxdRU\",\n            \"object_id\": 2484072,\n            \"object_name\": \"\u003cspan style=\\\"font-style: italic; opacity: 0.8;\\\"\u003eNo Name\u003c\\/span\u003e\",\n            \"object_name_plain\": null,\n            \"object_name_style\": [],\n            \"object_style\": [],\n            \"object_sources\": [],\n            \"object_version\": \"\",\n            \"object_dating\": \"2024-03-26T19:48:49Z\"\n        },\n        \"object_definitions\": {\n            \"4677\": {\n                \"object_description_id\": 4677,\n                \"object_definition_ref_object_id\": [\n                    2480431\n                ],\n                \"object_definition_value\": [\n                    \"clay\"\n                ],\n                \"object_definition_sources\": [],\n                \"object_definition_style\": []\n            },\n            \"4731\": {\n                \"object_description_id\": 4731,\n                \"object_definition_ref_object_id\": [\n                    2480363\n                ],\n                \"object_definition_value\": [\n                    \"baked\"\n                ],\n                \"object_definition_sources\": [],\n                \"object_definition_style\": []\n            },\n            \"4732\": {\n                \"object_description_id\": 4732,\n                \"object_definition_ref_object_id\": 2480382,\n                \"object_definition_value\": \"complete\",\n                \"object_definition_sources\": [],\n                \"object_definition_style\": []\n            },\n            \"4733\": {\n                \"object_description_id\": 4733,\n                \"object_definition_ref_object_id\": 2480383,\n                \"object_definition_value\": \"Excellent\",\n                \"object_definition_sources\": [],\n                \"object_definition_style\": []\n            },\n            \"4734\": {\n                \"object_description_id\": 4734,\n                \"object_definition_ref_object_id\": 2483824,\n                \"object_definition_value\": \"MRD Tall Ṣadūm\",\n                \"object_definition_sources\": [],\n                \"object_definition_style\": []\n            },\n            ...\n```\n\n**melkschaap output**\n\n```json\n{\n    \"id\": 2484072,\n    \"material\": [\n        {\n            \"id\": 2480431,\n            \"label\": \"clay\",\n            \"cdli_id\": 1\n        }\n    ],\n    \"material_aspect\": [\n        {\n            \"id\": 2480363,\n            \"label\": \"baked\",\n            \"cdli_id\": 10\n        }\n    ],\n    \"artifact_preservation\": {\n        \"id\": 2480382,\n        \"label\": \"complete\"\n    },\n    \"surface_preservation\": {\n        \"id\": 2480383,\n        \"label\": \"Excellent\"\n    },\n    \"provenience\": \"MRD Tall \\u1e62ad\\u016bm\",\n    \"period\": [\n        {\n            \"id\": 2480348,\n            \"label\": \"Old Babylonian (ca. 1900-1600 BC)\",\n            \"cdli_id\": 18\n        }\n    ],\n    \"written_in\": \"MRD Tall \\u1e62ad\\u016bm\",\n    \"museum_number\": \"O.223\",\n    \"accession_number\": \"NA\",\n    ...\n```\n\n## Credits\n\nDevelopment by [GhentCDH - Ghent University](https://www.ghentcdh.ugent.be/). Funded by the [GhentCDH research projects](https://www.ghentcdh.ugent.be/projects).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghentcdh%2Fmelkschaap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghentcdh%2Fmelkschaap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghentcdh%2Fmelkschaap/lists"}