Package: datatops
d a t a t o p sDatatops is a super-simple zero-auth zero-setup data storage and retrieval tool for all kinds of projects.OverviewIf you are looking for installation instructions, seeInstallation.Creating a new projectIf you already have a datatops server set up, you can create a new project like this:fromdatatopsimportDatatopsdt=Datatops("https://my-datatops-website.com")project=dt.create_project("my-survey")This will create a new project called "my-survey" on your datatops server.Theprojectvariable has some important details:>>>print(project)<Projectname="my-survey",url="https://my-datatops-website.com/projects/my-survey",user_key="s9bhn4kd",admin_key="a-f4001f00-152a-4a84-8eba-d352b5f00884">You will never be shown theadmin_keyagain, so make sure to save it somewhere safe. You will need it to read your data and manage the project later.IMPORTANT!By default, datatops will also store newly created projects in the~/.config/datatopsdirectory. If you're not on your own computer,STOPwhat you're doing and run this NOW:project.save_json("datatops_my-survey.json")This will save the project details to a file calleddatatops_my-survey.json.Saving dataWe will first save data to the project as an admin, and then we will see an example of how to use datatops to store data submitted by users.Saving data as an adminYou can use theprojectobject to store and retrieve data:project.store({"name":"Jordan","breakfast_juice":"grapefruit"})This will store the data in the project. You can store any JSON-serializable data.Saving data submitted by usersIf you want to allow users to submit data to your project, you can share theuser_keywith them. They can then use the user key to make requests to your datatops server.Saving data in PythonfromdatatopsimportDatatopsdt=Datatops("https://my-datatops-website.com")project=dt.get_project("my-survey",user_key="s9bhn4kd")project.store({"name":"Jordan","breakfast_juice":"grapefruit"})Saving data in JavaScriptThis example is most useful if your users are submitting data from a web app:fetch("https://my-datatops-website.com/api/v1/projects/my-survey",{method:"POST",headers:{"Content-Type":"application/json","X-Datatops-User-Key":"s9bhn4kd",},body:JSON.stringify({name:"Jordan",breakfast_juice:"grapefruit",}),});Retrieving dataIn order to retrieve data, you will need theadmin_keyfor the project. If you still have theprojectobject from before, you can use that. Otherwise, you can use theget_projectmethod:fromdatatopsimportDatatopsdt=Datatops("https://my-datatops-website.com")# If you're on your own computer and you have the# project saved in the ~/.config/datatops directory:project=dt.get_project("my-survey")# Or, if you saved your own copy of the project details:project=dt.get_project(json="datatops_my-survey.json")# Or, if you have the admin key:project=dt.get_project("my-survey",admin_key="a-f4001f00-152a-4a84-8eba-d352b5f00884")Once you have the project, you can retrieve the data:data=project.list_data()Is datatops right for me?If you check all of the following boxes (or mostly all of them), then datatops is probably right for you:I have a project that has no current backend or serverI need to save dataI am not using a databaseI am not using authentication or authorization toolsI need to store lots of relatively small (<100kb) recordsI will retrieve all (or almost all) of my records at onceMy users will never (or almost never) need to retrieve dataStarting a new serverfromdatatops.serverimportDatatopsServer,JSONFileBackendDatatopsServer(JSONFileBackend(path="mock-projects")).run(port=5001)You can also limit who can create a new project by passing aproject_creation_secretto theDatatopsServerconstructor:DatatopsServer(JSONFileBackend(path="mock-projects"),project_creation_secret="my-secret",).run(port=5001)Now in order to be allowed to create a new project, you will need to pass theproject_creation_secretargument:dt=Datatops("http://localhost:5001")dt.create_project("my-survey",project_creation_secret="my-secret",)Usage example>>>fromdatatopsimportDatatops>>>dt=Datatops("http://localhost:5001")>>>proj=dt.create_project("my_project5")>>>proj.store({"a":1,"b":2})>>>proj.list_data()