Provide API for country code list

Created on 4 April 2023, over 1 year ago
Updated 20 July 2023, about 1 year ago

Problem/Motivation

It would be useful to make the country code list available via an API endpoint.

Proposed resolution

Add a route that provides the list as JSON.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom malcomio

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @malcomio
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    I'm happy to review any provided MR's or patches. Could you elaborate on why you would need it?

  • 🇬🇧United Kingdom malcomio

    For our project, we have a potential requirement to have a phone number form decoupled from Drupal, as well as the field provided by this module.

    So we'd like both forms to use the same list.

    Perhaps not a very common requirement...

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sakthi_dev

    Created a patch for listing the countries. Please review.

  • Status changed to Needs work about 1 year ago
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    @sakthi_dev thank you for your contribution to this issue. I would like to highlight that you should use Drupal Best Practises and Coding Standards https://www.drupal.org/docs/develop/standards

    And I would like to have the API endpoint not behind and admin path? @malcomio do you have any suggestions?

    Also if we're going to provide an API to expose the country list, we should implement the getting of the list as a service and re-use the service for the fields and other places where the country list from the lib is used.

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    After discussion this on DDD Vienna, my suggestion for a path would be /api/phone-number/country-options

    And there is already a service providing the list, so please use that one to get the options.

Production build 0.71.5 2024