I tried to make a client of RESAS-API in Java

I wrote a client for RESAS API in Java

I have various data published by RESAS API, It's hard to get the data.

And once I made it, I thought it would be more convenient to share it with everyone. just made it. And I published it on github, but I can not find it so much, so I made an article.

RESAS-Client Java It is posted on github, so please git clone it from here or download it as a zip and use it.

https://github.com/code4nagoya/resas-client

Link to RESAS API list

https://opendata.resas-portal.go.jp/docs/api/v1/index.html https://opendata.resas-portal.go.jp/docs/api/v1/detail/index.html

Simple usage explanation Taking the number of inland fishing boats as an example

Each class has a Request and a Result, and a test class. It's a test class, and I've just seen myself test it by hand. Please as a sample (Please note that some test classes are organized, Sumanu (-people-;))

The class name and variables are created based on the URL for sending and receiving the RESAS API.

It has a name along the URL and a class like Request / Result / RequetTest.

If you want to get the data from the API of the number of inland fishing boats, the URL will be as follows.

Since the class name is created according to the URL, the class is named FisheryRiverBoatForStacked ***.

In the *** part, the class with the parameters for sending is Request, and the class with the parameters for receiving is Result.

-Class with HTTP request parameters FisheryRiverBoatForStackedRequest -Received class FisheryRiverBoatForStackedResult -Send class used in the test FisheryRiverBoatForStackedRequestTest

Send and API keys

To send, use the following class.

Try to match

Have me git clone Take a look at the FisheryRiverBoatForStackedRequestTest.

There is a sample in the test class, so please take a look. The following is an excerpt.

python



	@Test
	public void test() throws ParseException, IOException {
		ObjectMapper om = new ObjectMapper();

		List<String> paramNames = new ArrayList<String>();
		paramNames.add("prefCode");

		List<String> paramValues = new ArrayList<String>();

		paramValues.add("1");

		StringBuffer params = ResasUtil.addParameters(paramNames, paramValues);

		String result = ResasHttpAccess.sendString("api/v1" + FisheryRiverBoatForStackedRequest.url, params.toString());

		System.out.println(result);
		FisheryRiverBoatForStackedResult resultData = om.readValue(result,
				FisheryRiverBoatForStackedResult.class);

FisheryRiverBoatForStacked a = resultData.getResult();
    }

Finally

There is a general class, so please use it. Also, there are still many things that can be abstracted and easily done, so we look forward to your requests and help.

(゜ ∀ ゜) I hope the local area will be a wonderful city

Recommended Posts

I tried to make a client of RESAS-API in Java
I tried to make a login function in Java
I tried to make a parent class of a value object in Ruby
I tried to make a talk application in Java using AI "A3RT"
I tried to create a Clova skill in Java
I tried to convert a string to a LocalDate type in Java
[Java] I tried to make a maze by the digging method ♪
I tried to make Basic authentication with Java
java I tried to break a simple block
I did Java to make (a == 1 && a == 2 && a == 3) always true
I tried to implement deep learning in Java
I tried to create Alexa skill in Java
I tried to break a block with java (1)
I tried to make full use of the CPU core in Ruby
I tried metaprogramming in Java
I tried to implement Firebase push notification in Java
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried to implement the Euclidean algorithm in Java
~ I tried to learn functional programming in Java now ~
I tried to find out what changed in Java 9
[Small story] I tried to make the java ArrayList a little more convenient
I tried to make a sample program using the problem of database specialist in Domain Driven Design
I tried to make an application in 3 months from inexperienced
I tried to create a java8 development environment with Chocolatey
I tried to modernize a Java EE application with OpenShift.
I created a PDF in Java.
I tried to summarize the basics of kotlin and java
How to make a Java container
[Beginner] I made a program to sell cakes in Java
I want to make a specific model of ActiveRecord ReadOnly
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
I tried to make a message function of Rails Tutorial extension (Part 1): Create a model
I tried using Hotwire to make Rails 6.1 scaffold a SPA
I tried to make Java Optional and guard clause coexist
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried using JWT in Java
I tried to summarize Java learning (1)
I tried to implement a buggy web application in Kotlin
I tried to summarize Java 8 now
How to make a Java array
I tried using GoogleHttpClient of Java
I tried to make a product price comparison tool of Amazon around the world with Java, Amazon Product Advertising API, Currency API (2017/01/29)
I finished watching The Rose of Versailles, so I tried to reproduce the ending song in Java
I tried to make a reply function of Rails Tutorial extension (Part 3): Corrected a misunderstanding of specifications
I tried to make the sample application into a microservice according to the idea of the book "Microservice Architecture".
[Java] I tried to make a rock-paper-scissors game that beginners can run on the console.
I tried to create a simple map app in Android Studio
I tried to implement Ajax processing of like function in Rails
I tried to illuminate the Christmas tree in a life game
I tried to write code like a type declaration in Ruby
I tried setting Java beginners to use shortcut keys in eclipse
[Unity] I tried to make a native plug-in UniNWPathMonitor using NWPathMonitor
I tried to make an Android application with MVC now (Java)
I tried to summarize the methods of Java String and StringBuilder
I tried to make Numeron which is not good in Ruby
I tried to make a group function (bulletin board) with Rails
[Java] I participated in ABC-188 of Atcorder.
How to make a Java calendar Summary
I tried a calendar problem in Ruby
Easy to make Slack Bot in Java