https://github.com/making/jqiita
Qiita API Java Client
https://github.com/making/jqiita
Last synced: 12 months ago
JSON representation
Qiita API Java Client
- Host: GitHub
- URL: https://github.com/making/jqiita
- Owner: making
- Created: 2014-10-13T21:09:30.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-10-15T01:26:22.000Z (over 11 years ago)
- Last Synced: 2025-04-06T07:37:37.637Z (about 1 year ago)
- Language: Java
- Size: 211 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JQiita
[Qiita API v2](http://qiita.com/api/v2/docs) Java Client
## Usage
``` xml
am.ik.jqiita
jqiita
0.8.1
```
## How to use API
``` java
// list items
Qiita.client()
.items()
.list()
.forEach(System.out::println);
// output verbose Log
Qiita.given()
.log().all()
.client()
.items()
.list()
.forEach(System.out::println);
// list items by specific user
Qiita.client()
.items()
.listByUserId("making@github")
.stream()
.map(Item::getTitle)
.forEach(System.out::println);
// list items by specific tag
Qiita.client()
.items()
.listByTagId("Java")
.stream()
.map(Item::getTitle)
.forEach(System.out::println);
// with accessToken
Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.client()
.items()
.list()
.forEach(System.out::println);
// create item
Item item = Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.client()
.items()
.create(new ItemRequest(
"new item from JQiita",
"* hello world!",
Arrays.asList(new TagRequest("hoge"))));
System.out.println(item);
// update item
Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.client()
.items()
.update(item.getId(),
new ItemRequest("Title has changed!", "* foo bar!", Arrays.asList(new TagRequest("hoge"))));
// delete item
Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.client()
.items()
.delete(item.getId())
// for Qiita:Team
Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.host("https://xxxx.qiita.com")
.client()
.items()
.list()
.forEach(System.out::println);
```
**Note that `QiitaClient` is cached for each access token**. `Qiita.given().someConfigure()` is ignored once the client is created unless `QiitaClient#clearCache()` is called.
## How to set access token
Priority is "Programatic > System Property > Environment Variable".
### Programatic
``` java
QiitaClient client = Qiita.given()
.accessToken("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd")
.client();
// ...
```
### System Property
``` bash
-Djqiita.accessToken=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd
```
### Environment Variable
``` bash
export JQIITA_ACCESS_TOKEN=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd
```
## Requirements
* Java SE 8+
* [Retrofit](http://square.github.io/retrofit/)
* [Gson](https://code.google.com/p/google-gson/)
## License
Licensed under the Apache License, Version 2.0.