{"id":17070371,"url":"https://github.com/owainkenwayucl/uclapi-java","last_synced_at":"2026-01-19T18:11:21.134Z","repository":{"id":81522484,"uuid":"111984205","full_name":"owainkenwayucl/uclapi-java","owner":"owainkenwayucl","description":"Java access to the UCL API","archived":false,"fork":false,"pushed_at":"2019-07-12T10:24:08.000Z","size":64,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T23:41:22.772Z","etag":null,"topics":["clojure","java","jython","scala","ucl","uclapi"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/owainkenwayucl.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}},"created_at":"2017-11-25T07:09:00.000Z","updated_at":"2019-07-12T10:24:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f9f0a5d-2a5f-478d-bbb8-21bf985eb541","html_url":"https://github.com/owainkenwayucl/uclapi-java","commit_stats":{"total_commits":110,"total_committers":1,"mean_commits":110.0,"dds":0.0,"last_synced_commit":"18584135800ce5337235b1d65e63c8f2ef05a97d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/owainkenwayucl/uclapi-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fuclapi-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fuclapi-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fuclapi-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fuclapi-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owainkenwayucl","download_url":"https://codeload.github.com/owainkenwayucl/uclapi-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainkenwayucl%2Fuclapi-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28579059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T17:42:58.221Z","status":"ssl_error","status_checked_at":"2026-01-19T17:40:54.158Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["clojure","java","jython","scala","ucl","uclapi"],"created_at":"2024-10-14T11:30:45.464Z","updated_at":"2026-01-19T18:11:21.105Z","avatar_url":"https://github.com/owainkenwayucl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"UCL API Java library\n====================\n\nThis repository contains code for accessing the [UCL API](https://uclapi.com/) using Java.  I started this work as part of [#LearnHack 4.0](https://sites.google.com/site/ucllearnhack/learnhack) but it shall continue!\n\n*(You can find the tagged release from #LearnHack 4.0 [here](https://github.com/owainkenwayucl/uclapi-java/releases/tag/LearnHack4.0))*\n\nThis library provides access to and classes to represent objects returned by all the public (i.e. non-OAuth authenticated) UCL API end points.  As well as Java this libary of course works in languages that are hosted in the JVM, for example Clojure, Scala or Jython.\n\nInstallation:\n------------\n\n### Requirements:\n\n* Java JDK (tested on 11 and 8, should work on 7)\n* GNU Make (automated build)\n* An API key (instructions on [UCL-API](https://uclapi.com/) website)\n* JSON.simple (https://code.google.com/archive/p/json-simple/ or Ubuntu/Debian package `libjson-simple-java` to parse JSON objects.  If you only want to use `uclapi.UCLApiConnection` you don't need this, but will need to build that class manually in the normal way.)  \n\n*Note* - the ownership of JSON.simple has recently changed and the new developers are changing the API.  For now you should use version 2.x which is backwards compatible with version 1.x but will get deprecation warnings when you compile.  I am looking at migrating this code to the new API.\n\nClone the repository and run `make`.  By default this builds `.class` files in the `uclapi` directory but you can also build a `.jar` file by running `make jar` and JavaDoc documentation by running `make javadoc` or everything by running `make all`.\n\nAdd the directory (or `.jar` if you built it) to your java class path. \u003c- **IMPORTANT**\n\nYou can then write a simple example program (`examples/search.java`) to do a query, as per the examples on the UCL API website:\n\n```java\n// UCL API example in Java\n// This example searchs for people.\n//\n// Owain Kenway\n\npackage examples;\n\nimport uclapi.UCLApiConnection;\nimport uclapi.Person;\n\n\npublic class search {\n    public static void main(String[] args) {\n        if (args.length == 2) {\n\n            // Get our response out of the UCL API\n            UCLApiConnection conn = new UCLApiConnection(args[0]);\n\n            Person[] people = Person.searchAPI(conn, args[1]);\n\n            for (int i = 0; i \u003c people.length; i++) {\n                System.out.println(people[i].toString());\n            }\n\n\n        } else {\n            System.err.println(\"Run with API key + query as arguments.\");\n            System.exit(1);\n        }\n    }\n}\n```\n\nCompile this code and run it with your API key as the first argument, and part of a person's name as the second.\n\n```none\n$ javac examples/search.java\n$ java examples/search \u003cinsert your API key here\u003e Kenway\n```\n\nIf all things are working this should print out a list of people whose names contain \"Kenway\".\n\n### Clojure\n\nSince Clojure can access Java classes, you also call this library from Clojure.  The following code does essentially the same as the above java code.\n\n```clojure\n; Person Search example in Clojure.\n; Owain Kenway\n\n; Get command line arguments (should be key followed by query)\n(if (not= (count *command-line-args*) 2)\n  ((.println System/err \"Run with API key + query as arguments.\")\n   (System/exit 1))\n)\n\n(def token (first *command-line-args*))\n(def query (second *command-line-args*))\n\n; Now we've got this far import our library.\n\n(import uclapi.UCLApiConnection)\n(import uclapi.Person)\n\n; Do our search and print out results in a single line!\n(println (clojure.string/join \"\\n\" (Person/searchAPI (UCLApiConnection. token) query)))\n```\n\nIf you have the Debian/Ubuntu `clojure wrappers` you can then run this code with:\n\n```none\n$ clojure examples/search.clj \u003cinsert your API key here\u003e Kenway\n```\n\nAlternative wrappers may be found here: https://github.com/owainkenwayucl/clojure-wrappers\n\n\n### Scala\n\nAs with Clojure, you can call this library from Scala.  The following code does the same as the above two examples.\n\n```scala\n// Person Search example in Scala.\n// Owain Kenway\n\npackage examples\n\nimport uclapi.UCLApiConnection\nimport uclapi.Person\n\nobject search extends App {\n\n    if (args.length != 2) {\n        Console.err.println(\"Run with API key + query as arguments.\")\n        System.exit(1)\n    }\n\n    val apikey = args(0)\n    val query = args(1)\n\n    val results = Person.searchAPI(new UCLApiConnection(apikey), query)\n\n    for (i \u003c- 0 to (results.length - 1))\n        println(results(i).toString())\n}\n```\n\nYou can compile this code with `scalac` and then run it.\n\n```none\n$ scalac examples/search.scala\n$ scala examples.search \u003cinsert your API key here\u003e Kenway\n```\n\n### Jython\n\nAnd of course you can use Jython:\n\n```python\n# UCL API example in Jython\n# This example searches for people.\n\n# Owain Kenway\n\nimport uclapi.UCLApiConnection\nimport uclapi.Person\n\nimport sys\n\n# Get our key + query.\nif len(sys.argv) != 3:\n\tsys.exit(\"Call with query as argument\")\n\nkey = sys.argv[1]\nquery = sys.argv[2]\n\n# Make our connection and get our results.\nconn = uclapi.UCLApiConnection(key)\nresults = uclapi.Person.searchAPI(conn, query)\n\n# Print them out.\nfor a in results:\n\tprint(a.toString())\n```\n\nAnd run it through `jython`.\n\n```none\n$ jython examples/search.py \u003cinsert your API key here\u003e Kenway\n```\n\nQuestions/Comments?\n-------------------\n\nThe best way to contact me is on [Twitter](https://twitter.com/owainkenway), although you can open an Issue too.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainkenwayucl%2Fuclapi-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowainkenwayucl%2Fuclapi-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainkenwayucl%2Fuclapi-java/lists"}