{"id":24388217,"url":"https://github.com/frewtypebbles/jsonqm","last_synced_at":"2026-04-25T13:37:49.043Z","repository":{"id":172990278,"uuid":"650061507","full_name":"FrewtyPebbles/jsonQM","owner":"FrewtyPebbles","description":"A JSON query model tool that makes API requests more versatile.","archived":false,"fork":false,"pushed_at":"2024-06-12T22:13:09.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-29T12:24:59.909Z","etag":null,"topics":["json","json-api","model","query"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/jsonQM/","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/FrewtyPebbles.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-06T08:52:21.000Z","updated_at":"2024-06-12T22:13:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"2848ead6-cbbb-4cfe-b55a-57b4ec1663eb","html_url":"https://github.com/FrewtyPebbles/jsonQM","commit_stats":null,"previous_names":["frewtypebbles/api-query-language","frewtypebbles/jsonqm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FrewtyPebbles/jsonQM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrewtyPebbles%2FjsonQM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrewtyPebbles%2FjsonQM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrewtyPebbles%2FjsonQM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrewtyPebbles%2FjsonQM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrewtyPebbles","download_url":"https://codeload.github.com/FrewtyPebbles/jsonQM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrewtyPebbles%2FjsonQM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32264431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["json","json-api","model","query"],"created_at":"2025-01-19T13:56:41.480Z","updated_at":"2026-04-25T13:37:49.003Z","avatar_url":"https://github.com/FrewtyPebbles.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonQM\n\nA simple tool that can make your API endpoint json queries more functional.\n\n`pip install jsonQM`\n\n## Quick Start\n\nThe example model explains how to set up a model and query that model.\n\n*tests/ExampleModel.py*\n\n```py\nfrom jsonQM import *\n\n# Make the model.\n\n# Declare a model serializer\nms = ModelSerializer() # Each model must have its own serializer\nclass MyModel(Model):\n    def __init__(self) -\u003e None:\n        # define the structure of the query model:\n        self.model = {\n            # we have a single query scope/section called functions\n            \"functions\":{},\n            \"msg\":\"test\" # non functional attributes also need to be included in the json query if you wish for them to be present in the response (see Example query 3 below)\n        }\n        # sync/add the model attribute functions to the model\n        ms.sync(self)\n        \n    # Define attributes of the model (argument 2) along with the scope/section they are found in (argument 1)\n    @ms.add([\"functions\"], \"repeater\")  # This attribute key is \"repeater\" and can be found in the \"functions\" dict\n    def repeater(self, arg:int):\n        # when the attribute is queried it will run this code and return the value\n        return [\"repeat\" for _ in range(arg)]\n\n    # You can use anything as the attribute key that is a valid python dictionary key.\n    @ms.add([\"functions\"], 7)# Keep in mind that if used with json, you are limited to what is a valid json key.\n    def number_7(self):\n        return \"abc\"\n    \n    @ms.token()# this marks this attribute as the model's token\n    @ms.add([], \"token\")\n    def token(self, tok:str):\n        #insert some logic to compare token to tokens in database\n        return tok == \"token\" # The token function must return true for the token to be valid.\n    \n\n    @ms.requires_token()# this marks this attribute as requiring the token attribute to return true\n    @ms.add([], \"secret\")\n    def secret(self):\n        return \"My super secret message\" # if the token is false this will return 'errot:token:invalid' if the token is missing from the query this will return 'error:token:missing'\n\n#LOGIC\nif __name__ == \"__main__\":\n    # If you are experiencing bugs related to concurrency, you should reinstantiate your model per thread/concurrent task where it is being used.\n    # note that instantiation may require many itterations depending on the ammount of attributes you've added and the length of their parent path.\n    # (parent path is the first list argument in `ms.add([\"some\",\"dictionary\",\"key\",\"path\"], \"attribute name\")`)\n    model_instance = MyModel()\n\n    # If you can avoid instantiating the model more than once for optimal performance.\n\n    #Example query 1\n    print(model_instance.get({\n        \"functions\":{\n            # programmed attribute values should be a list containing the function arguments.\n            \"repeater\":[5],\n            7:[]\n        }\n    }))\n\n    # prints:\n    # {'functions': {'repeater': ['repeat', 'repeat', 'repeat', 'repeat', 'repeat'], 7: 'abc'}}\n\n    #Example query 2\n    print(model_instance.get({\n        \"functions\":{\n            # The model will only run/return attributes which have been specified\n            \"repeater\":[5]\n        }\n    }))\n\n    # prints:\n    # {'functions': {'repeater': ['repeat', 'repeat', 'repeat', 'repeat', 'repeat']}}\n\n    #Example query 3\n    print(model_instance.get({\n        \"token\":[\"token\"],\n        \"secret\":[]\n    }))\n\n    # prints:\n    # {'token': True, 'secret': 'My super secret message'}\n\n    #Example query 3\n    print(model_instance.get({\n        \"token\":[\"abc\"],\n        \"secret\":[]\n    }))\n\n    # prints:\n    # {'token': False, 'secret': 'error:token:invalid'}\n\n    #Example query 3\n    print(model_instance.get({\n        \"secret\":[]\n    }))\n\n    # prints:\n    # {'secret': 'error:token:missing'}\n\n    #Example query 3\n    print(model_instance.get({\n        \"msg\":1\n    }))\n\n    # prints:\n    # {'msg': 'test'}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrewtypebbles%2Fjsonqm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrewtypebbles%2Fjsonqm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrewtypebbles%2Fjsonqm/lists"}