Wikidata / Wikidata-Toolkit

Java library to interact with Wikibase
https://www.mediawiki.org/wiki/Wikidata_Toolkit
Apache License 2.0
374 stars 99 forks source link

Component for Wikibase API access #11

Closed mkroetzsch closed 9 years ago

mkroetzsch commented 10 years ago

There should be a component for accessing the functions of the Wikibase Web API. Initially, this component should only support some of the basic reading operations; other operations will be added later. It should be configured by providing the base URL of the API endpoint of the Wikibase instance to access. A JSON parser and URL manipulation libraries should be used to cleanly interact with the API.

guenthermi commented 10 years ago

I have written a class to configure the connection to the WikibaseApi and send queries. Another class should contain methods for the use cases. So I started to implement a mehtod which read out the datatype from the property-id. The API response something like "time" for P569 or "wikibase-item" for P553. Should that be converted in one of the constants from the DatatypeIdValue interface?

mkroetzsch commented 10 years ago

Very good. Yes, the strings from the JSON should be represented by the corresponding datatype contents in our code.

Btw, I have also written some basic Web access components for the dump file downloading. These might be handy later on, especially for testing, since there are mock implementations of the interface. So you don't need to focus on the code that fetches string data from the web.

eldur commented 10 years ago

... Maybe interesting for you ;-)

mkroetzsch commented 10 years ago

This is very interesting indeed. Should we make use of (parts of) jwbf in out code? Or the other way around (e.g., we already have the Wikidata data model and we will implement the Wikidata JSON serialization)? Our goal is to publish such features as independent Maven modules, so one could pull in parts without pulling in everything. However, I don't know jwbf and its architecture enough to say what could work here.

eldur commented 10 years ago

I'll offer the same points from the referenced issue - if you interested in.

JWBF is only a minimal service layer. You'll get, in your case, shortcuts for login, token handling, encoding and a few simple utils like a APIRequestBuilder (and the offered changes for API integration tests / not wikidata specific)

fer-rum commented 10 years ago

Via mailing list since this might interest others too:

I did a quick review of the JWBF as it was proposed to be used with
wikidata as well.

Code quality and style is pretty high, everything looks clean and
straight forward. The documentation is very sparse, but it seems to be
worked on.

Depending on how much the MediaWiki API and the Wikidata API differ
from each other it would take some coding effort to get the bots
running with the WDTK. As it looks in the github repository the
developers already tried to play around with this [0].

So I propose the following:

Reaching the first milestone of the WDTK would be a good time for a
first handshake between the projects.

Sincerly, Fredo Erxleben

[0]
https://github.com/eldur/jwbf/commit/74970a3675c57be413e92e0538b5317985180e96

Zitat von Markus Krötzsch notifications@github.com:

This is very interesting indeed. Should we make use of (parts of)
jwbf in out code? Or the other way around (e.g., we already have the
Wikidata data model and we will implement the Wikidata JSON
serialization)? Our goal is to publish such features as independent
Maven modules, so one could pull in parts without pulling in
everything. However, I don't know jwbf and its architecture enough
to say what could work here.


Reply to this email directly or view it on GitHub: https://github.com/Wikidata/Wikidata-Toolkit/issues/11#issuecomment-36115453

eldur commented 10 years ago

I tried to get the full rundtrip:

but how can I map the json response to a org.wikidata.wdtk.datamodel.interfaces.Claim?

eldur/jwbf@698b478

eldur commented 10 years ago

Hi fer-rum, thanks for your comment ... now I get a JsonException at eldur/jwbf@82acd0d

mkroetzsch commented 9 years ago

Pull request #123 introduces basic capabilities for fetching entity data via the API. It is not currently planned to add write access (JWBF would be much better suited to support the related aspects), but the code might be useful as an example on how to parse JSON data (which works well by now).

mkroetzsch commented 9 years ago

Closed by merging #123.