ashleighsims/companies-house-api-wrapper

Companies House API的包装器。涵盖了开发人员可用的所有端点。

1.0.0 2020-02-19 10:57 UTC

This package is auto-updated.

Last update: 2024-09-28 20:14:52 UTC


README

这是一个针对Companies House API的PHP包装器。已经添加了Laravel的自动发现,因此您应该能够直接在Laravel中使用它。

当使用此包装器时,建议使用环境文件来存储API密钥和基础URL。这确保了您不会在应用程序的源代码中留下任何API密钥,也不会将其提交到任何版本控制中。

目前不包括可用的Document API。

安装

在您开始使用Companies House API之前,您需要在您的companies house开发者账户中注册您的应用程序:https://developer.companieshouse.gov.uk/developer/applications

您在通过Companies House注册应用程序时提供的API密钥是必需的。

通过Composer

$ composer require ashleighsims/companies-house-api-wrapper

Laravel

如果您在Laravel中使用此包,则已启用自动发现,因此您应该能够立即开始使用(当使用Laravel 5.5及以上版本时)。

如果您没有使用Laravel 5.5及以上版本,则需要手动注册一些内容...

在app.php文件中注册提供者

AshleighSims\CompaniesHouseApiWrapper\Laravel\CompaniesHouseApiWrapperServiceProvider::class

可选地注册外观

'GetAddress' => AshleighSims\CompaniesHouseApiWrapper\Laravel\CompaniesHouseApiWrapperServiceProvider::class

请确保在开始之前将以下环境变量添加到您的.env文件中。

环境变量

将以下环境变量添加到您的.env文件中。

COMPANIES_HOUSE_API_BASE_URL="https://api.companieshouse.gov.uk/"
COMPANIES_HOUSE_API_KEY="your-api-key-from-companies-house"

用法

这涵盖了截至2020年2月18日Companies House网站上所有可用的端点。

以下列出了每个端点及其代码示例。对于Laravel用户,您可以通过构造函数或外观使用CompaniesHouseApiWrapper进行类型提示。

Laravel

通过控制器进行依赖注入

use AshleighSims\CompaniesHouseApiWrapper\CompaniesHouseApiWrapper;
...

private $companiesHouse;

public function __construct(CompaniesHouseApiWrapper $companiesHouse) {
    $this->companiesHouse = $companiesHouse;
}

public function getAddress() {
    $response = $this->companiesHouse->registeredOfficeAddress()->get('00014259');
}

...

外观

use AshleighSims\CompaniesHouseApiWrapper\Laravel\Facades\CompaniesHouseApiWrapper;

...

public function getAddress() {
    $response = CompaniesHouseApiWrapper::registeredOfficeAddress()->get('00014259');
}

...

通用用法

搜索

搜索全部

参数

  • 查询(在这种情况下为人员的姓名)

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->search()->searchAll('Your Query Here'); // Returns a json_decoded associative array
搜索公司

参数

  • 查询(在这种情况下为人员的姓名)

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->search()->searchCompany("Deathstar Co"); // Returns a json_decoded associative array
搜索官员

参数

  • 查询(在这种情况下为人员的姓名)

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->search()->searchOfficer("Luke Skywalker"); // Returns a json_decoded associative array
搜索被除名的官员

参数

  • 查询(在这种情况下为人员的姓名)

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->search()->searchDisqualifiedOfficer("Finn FN-2187"); // Returns a json_decoded associative array

公司概况

获取

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->companyProfile()->get("00014259"); // Returns a json_decoded associative array

注册办公地址

获取

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->registeredOfficeAddress()->get("00014259"); // Returns a json_decoded associative array

公司官员

列表

参数

  • 公司编号

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
  • 注册类型(允许的选项:directors, secretaries, llp-members)- 仅在注册视图为true时生效
  • 注册视图(允许的选项:true或false,默认:false)
  • 排序方式(允许的选项:appointed_on, resigned_on, surname)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->companyOfficers()->list("00014259"); // Returns a json_decoded associative array

提交历史

获取

参数

  • 公司编号
  • 事务ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->filingHistory()->get("00014259", "MzI1Mjg3MzI5MGFkaXF6a2N4"); // Returns a json_decoded associative array
列表

参数

  • 公司编号

可选参数

  • 类别(以逗号分隔)
  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->filingHistory()->list("00014259"); // Returns a json_decoded associative array

破产

获取

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->insolvency()->get("00014259", "MzI1Mjg3MzI5MGFkaXF6a2N4"); // Returns a json_decoded associative array

费用

获取

参数

  • 公司编号
  • 费用ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->charges()->get("00014259", "D0ReqeVClRjR7C-o5ySBBRZnxvU"); // Returns a json_decoded associative array
列表

参数

  • 公司编号

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->charges()->list("00014259"); // Returns a json_decoded associative array

官员任命列表

列表

参数

  • 官员ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->officerAppointmentList()->list("hLPe3meaIVQ0pqqn5AmvvS_V8pA"); // Returns a json_decoded associative array

官员除名

获取自然人

参数

  • 官员ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->officerDisqualifications()->getNatural("Ff-EjRku_DxTJnG6uBq2ie8jmLc"); // Returns a json_decoded associative array
获取法人

参数

  • 官员ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->officerDisqualifications()->getCorporate("Ff-EjRku_DxTJnG6uBq2ie8jmLc"); // Returns a json_decoded associative array

英国企业实体

列表

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->ukEstablishmentCompanies()->list("00014259"); // Returns a json_decoded associative array

具有重大控制权的人员

列表

参数

  • 公司编号

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
  • 注册视图(允许的选项:true或false,默认:false)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->list("00014259"); // Returns a json_decoded associative array
获取个人

参数

  • 公司编号
  • PSC ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->getIndividual("06637776", "tRjwr1Q2U9uhtZ86JoeexAKF1Co"); // Returns a json_decoded associative array
获取法人

参数

  • 公司编号
  • PSC ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->getCorporateEntities("00014259", "kISgW15ODWvznzBMq6Tv6ObCsLg"); // Returns a json_decoded associative array
获取法人实体

参数

  • 公司编号
  • PSC ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->getLegalPersons("00014259", "a-legal-persons-officer-id"); // Returns a json_decoded associative array
列出声明

参数

  • 公司编号

可选参数

  • 每页项目数(默认为35)
  • 起始索引(默认为0)
  • 注册视图(允许的选项:true或false,默认:false)
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->listStatements("00014259", "a-legal-persons-officer-id"); // Returns a json_decoded associative array
获取声明

参数

  • 公司编号
  • 声明ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->getStatement("00014259", "statement-id"); // Returns a json_decoded associative array
获取超级安全人员

参数

  • 公司编号
  • 超级安全ID
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->personsWithSignificantControl()->getSuperSecurePerson("00014259", "super-secure-id"); // Returns a json_decoded associative array

公司登记册

获取

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->companyRegisters()->get("00014259"); // Returns a json_decoded associative array

公司豁免

获取

参数

  • 公司编号
$companiesHouse = new CompaniesHouseApiWrapper('your-api-key', 'https://api.companieshouse.gov.uk/');
$response = $companiesHouse->companyExemptions()->get("00014259"); // Returns a json_decoded associative array

变更日志

请参阅变更日志以获取有关最近更改的更多信息。

安全

如果您发现任何与安全相关的问题,请通过电子邮件发送至 sims@ashleighsims.co.uk,而不是使用问题跟踪器。

许可证

许可证。请参阅许可证文件以获取更多信息。