法人番号API×kintone連携で法人情報を取得しよう

こんにちは。武井です。

今回は、kintoneと法人番号APIを連携して、
法人情報を取得する方法を綴ります。

法人番号とは

2013年に成立した法律によって、それぞれの法人に割り振られた番号です。

法人番号システム Web-APIとは

国税庁ウェブサイトで公開している、法人情報を取得するためのAPIです。

やること

  • kintoneのフォームに法人番号を入力すると、自動で法人情報が取得される
  • 情報更新日と都道府県を入力すると、自動で法人情報が取得される

kintoneにアプリ作成

kintoneに以下のようなフォームを持つアプリを作成します。

201609151337

※フィールドコードはフィールド名と同じです。
※テーブルのフィールドコードは「table」です。

JavaScript

(function () {
	"use strict";

	/**
	 * jQuery.ajax mid - CROSS DOMAIN AJAX
	 * ---
	 * @author James Padolsey (http://james.padolsey.com)
	 * @version 0.11
	 * @updated 12-JAN-10
	 * ---
	 * Note: Read the README!
	 * ---
	 * @info http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
	 */

	jQuery.ajax = (function (_ajax) {

		var protocol = location.protocol,
				hostname = location.hostname,
				exRegex = RegExp(protocol + '//' + hostname),
				YQL = 'http' + (/^https/.test(protocol) ? 's' : '') + '://query.yahooapis.com/v1/public/yql?callback=?',
				query = 'select * from html where url="{URL}" and xpath="*"';

		function isExternal(url) {
			return !exRegex.test(url) && /:\/\//.test(url);
		}

		return function (o) {

			var url = o.url;

			if (/get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url)) {

				// Manipulate options so that JSONP-x request is made to YQL

				o.url = YQL;
				o.dataType = 'json';

				o.data = {
					q: query.replace(
							'{URL}',
							url + (o.data ?
									(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
									: '')
							),
					format: 'xml'
				};

				// Since it's a JSONP request
				// complete === success
				if (!o.success && o.complete) {
					o.success = o.complete;
					delete o.complete;
				}

				o.success = (function (_success) {
					return function (data) {

						if (_success) {
							// Fake XHR callback.
							_success.call(this, {
								responseText: (data.results[0] || '')
										// YQL screws with <script>s
										// Get rid of them
										.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
							}, 'success');
						}

					};
				})(o.success);

			}

			return _ajax.apply(this, arguments);

		};

	})(jQuery.ajax);

	kintone.events.on(['app.record.edit.change.法人番号', 'app.record.create.change.法人番号', 'app.record.edit.change.情報更新日2', 'app.record.create.change.情報更新日2', 'app.record.edit.change.都道府県', 'app.record.create.change.都道府県'], function (event) {
		var record = event.record;
		//2015-12-01より前の情報はAPIの仕様でGETできない
		if (record.情報更新日2.value && parseInt(new Date(record.情報更新日2.value) / 1000) < 1448928000) {
			event.error = "情報更新日は2015年12月1日以降にしてください。";
			return event;
		} else if (!record.法人番号.value && (!record.情報更新日2.value || !record.都道府県.value)) {
			return event;
		}
		new kintone.Promise(function (resolve, reject) {
			setLoading();
			record.法人名.value = "";
			record.情報更新日.value = "";
			record.情報変更日.value = "";
			record.郵便番号.value = "";
			record.住所.value = "";
			var newRow = {
				type: "SUBTABLE",
				value: [{
						id: null,
						value: {
							法人番号2: {
								type: 'SINGLE_LINE_TEXT',
								value: undefined
							},
							法人名2: {
								type: 'SINGLE_LINE_TEXT',
								value: undefined
							},
							情報変更日2: {
								type: 'DATE',
								value: undefined
							},
							郵便番号2: {
								type: 'SINGLE_LINE_TEXT',
								value: undefined
							},
							住所2: {
								type: 'SINGLE_LINE_TEXT',
								value: undefined
							}
						}
					}]
			};
			record.table = newRow;

			var searchType = "", number = "", fromTo = "", address = "";
			if (event.type === "app.record.edit.change.法人番号" || event.type === "app.record.create.change.法人番号") {
				searchType = "num";
				number = record.法人番号.value;
			} else {
				searchType = "diff";
				fromTo = record.情報更新日2.value;
				address = record.都道府県.value;

				var cityCode = {
					北海道: "01",
					青森県: "02",
					岩手県: "03",
					宮城県: "04",
					秋田県: "05",
					山形県: "06",
					福島県: "07",
					茨城県: "08",
					栃木県: "09",
					群馬県: "10",
					埼玉県: "11",
					千葉県: "12",
					東京都: "13",
					神奈川県: "14",
					新潟県: "15",
					富山県: "16",
					石川県: "17",
					福井県: "18",
					山梨県: "19",
					長野県: "20",
					岐阜県: "21",
					静岡県: "22",
					愛知県: "23",
					三重県: "24",
					滋賀県: "25",
					京都府: "26",
					大阪府: "27",
					兵庫県: "28",
					奈良県: "29",
					和歌山県: "30",
					鳥取県: "31",
					島根県: "32",
					岡山県: "33",
					広島県: "34",
					山口県: "35",
					徳島県: "36",
					香川県: "37",
					愛媛県: "38",
					高知県: "39",
					福岡県: "40",
					佐賀県: "41",
					長崎県: "42",
					熊本県: "43",
					大分県: "44",
					宮崎県: "45",
					鹿児島県: "46",
					沖縄県: "47"
				};

				address = cityCode[address];
			}
			// 法人情報GET
			$.ajax({
				type: 'GET',
				url: 'https://api.houjin-bangou.nta.go.jp/1/' + searchType + '?id=xxxxxxx//法人番号ID///&number=' + number + '&from=' + fromTo + '&to=' + fromTo + '&address=' + address + '&type=12',
				crossDomain: true,
				dataType: 'xml',
				success: function (resp) {
					if (resp.responseText !== "") {
						// 取得した情報をXMLにパース
						var xml = $.parseXML(resp.responseText);
						if (searchType === "num") {
							record.法人名.value = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[6].innerHTML;
							record.情報更新日.value = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[4].innerHTML;
							record.情報変更日.value = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[5].innerHTML;
							record.郵便番号.value = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[7].childNodes[4].childNodes[2].innerHTML;
							record.住所.value = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[7].childNodes[1].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[7].childNodes[2].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[4].childNodes[7].childNodes[3].innerHTML;
						} else {
							var count = parseInt(xml.childNodes[0].childNodes[1].childNodes[0].childNodes[1].innerHTML, 10);
							if (count > 0) {
								if(count > 50)count = 50;
								for (var i = 0; i < count; i++) {
									var post;
									if (xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes.length !== 1) {
										if (typeof (xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[4].childNodes[2]) !== "undefined") {
											post = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[4].childNodes[2].innerHTML;
										} else {
											post = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[7].innerHTML;
										}
									} else {
										post = xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[12].childNodes[2].innerHTML;
									}
									var subRowOhmura = {
										value: {
											法人番号2: {
												type: 'SINGLE_LINE_TEXT',
												value: xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[1].innerHTML
											},
											法人名2: {
												type: 'SINGLE_LINE_TEXT',
												value: xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[6].innerHTML
											},
											情報変更日2: {
												type: 'DATE',
												value: xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[5].innerHTML
											},
											郵便番号2: {
												type: 'SINGLE_LINE_TEXT',
												value: post
											},
											住所2: {
												type: 'SINGLE_LINE_TEXT',
												value: (xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes.length !== 1) ? xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[1].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[2].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[7].childNodes[3].innerHTML : xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[9].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[10].innerHTML + xml.childNodes[0].childNodes[1].childNodes[0].childNodes[(i + 4)].childNodes[11].innerHTML
											}
										}
									};
									record.table.value.push(subRowOhmura);
								}
								record.table.value.shift();
							}
						}
						kintone.app.record.set(event);
						resolve();
					} else {
						resolve("miss");
					}
				},
				error: function (resp) {
					resolve();
				}
			});
		}).then(function (resp) {
			removeLoading();
			kintone.app.record.set(event);
			if (resp === "miss") {
				event.error = "入力内容を見直してください。";
			}
			return event;
		});
	});

	// ローディング画面を出す関数
	function setLoading() {
		var $body = $('body');
		$body.css('width', '100%');

		var $loading = $('<div>').attr('id', 'loading').attr('class', 'loading')
				.attr('style', 'width: 100%; height: 100%; position:absolute;' +
						' top:0; left:0; text-align:center; background-color:#666666; opacity:0.6; z-index: 9;');
		var $div = $('<div>').attr('id', 'imgBox').attr('style', 'width: 100%; height: 100%;');
		var $img = $('<img>').attr('src', 'data:image/gif;base64,R0lGODlhZABkAPQAAAAAAP///3BwcJaWlsjIyMLCwqKiouLi4uzs7NLS0qqqqrKysoCAgHh4eNra2v///4iIiLq6uvT09AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAHAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAZABkAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zfMgoDw0csAgSEh/JBEBifucRymYBaaYzpdHjtuhba5cJLXoHDj3HZBykkIpDWAP0YrHsDiV5faB3CB3c8EHuFdisNDlMHTi4NEI2CJwWFewQuAwtBMAIKQZGSJAmVelVGEAaeXKEkEaQSpkUNngYNrCWEpIdGj6C3IpSFfb+CAwkOCbvEy8zNzs/Q0dLT1NUrAgOf1kUMBwjfB8rbOQLe3+C24wxCNwPn7wrjEAv0qzMK7+eX2wb0mzXu8iGIty1TPRvlBKazJgBVnBsN8okbRy6VgoUUM2rcyLGjx48gQ4ocSbKkyZMoJf8JMFCAwAJfKU0gOUDzgAOYHiE8XDGAJoKaalAoObHERFESU0oMFbF06YikKQQsiKCJBYGaNR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KAIVX/MDhQsqQElBUFNFCAjUWBli0dGGSEyUQbn2xKOOI5IigAo0V/pmBQIEIBgigg4MS5MynQoz1FBEWKtatVrVuzel2h4GlTflGntnzGFexYrErdckXaiGjbEv6aEltxc+qbFHfD2hUr+GvXuIfFmmD6NEJVEg1Y4oQJtC3ixDwtZzWqWfGJBksajmhA0iTllCk+ikbNurXr17Bjy55Nu7bt20HkKGCwOiWDBAeC63S4B1vvFAIIBF+e4DEuAQsISCdHI/Ly5ad1QZBeQLrzMssRLFdgDKF0AgUUybB+/YB6XiO7Sz9+QkAE8cEREPh+y8B5hjbYtxxU6kDQAH3I7XEgnG4MNujggxBGCAVvt2XhwIUK8JfEIX3YYsCFB2CoRwEJJEQAgkM0ANyFLL7HgwElxphdGhCwCKIDLu4QXYwEUEeJAAnc6EACOeowAI8n1TKAjQ74uIIAo9Bnn4kRoDgElEEmQIULNWY54wkMjAKSLQq+IMCQQwZp5UVdZpnkbBC4OeSXqCXnJpG1qahQc7c1wAADGkoo6KCEFrpCCAA7AAAAAAAAAAAA');
		$loading.append($div.append($img));
		$body.append($loading);

		$('#imgBox').attr('style', 'margin-top: ' + Math.floor($('#loading').height() / 2) + 'px;');

		$body.css('position', 'fixed');

		var autoRemoveCnt = 0;
		var autoRemoveInterval = setInterval(function () {
			autoRemoveCnt++;
			if (autoRemoveCnt > 9) {
				clearInterval(autoRemoveInterval);
				removeLoading();
			}
		}, 1000);
	}

	// ローディング画面を消す関数
	function removeLoading() {
		var $loading = $('.loading');
		$loading.remove();

		var $body = $('body');
		$body.css('position', '');
	}

})();

4~78行目は、クロスドメインで取得できないと思しき法人番号APIを取得できるようにしてくれる優れものです。

動作

このようになります。

corpnum

感想

法人番号が分かれば法人情報の取得が容易

期間指定検索は検索結果が多くなりやすい

×法人名で検索することはできない(国税庁ウェブサイトのみ可)
×全件データの取得も国税庁ウェブサイトから手動によるダウンロードしかできない


▼複数製品も同時に無料お試し!▼