Country codes for country_id

I am sure i have seen it somewhere in the docs, but cannot find it any longer

What are the requirements for create > client country_id
if i dont include it, it sets the country to India

Can anyone point me in the right direction, as i have searched google for country codes, but they do not seem to match single numbers, etc.
If i try adding GBP, i just get an error, as it needs to be an number
Surely i dont need to add a php library to look up all countries ID’s?
Or if i do, can anyone make suggestions please?

Thanks
Jon

I could be wrong, but I think you might be looking for the ISO two-letter country code:

Additionally, here is a list of all Alpha-2, Alpha-3, and 3 digit UN codes:

Both of those came up as the first two options in a web search.

1 Like

Thank you Northhill

It is the ISO 3166 that they require.
I was hoping there was something that was within the ninja code that would help select this.
Most my customers are from the same country, so i could hard code it, but the odd few may want a different country.
I feel it would be better if a string could be used for the displayed country on invoice, as appose to needing to enter the ISO numbers.

I have however also quickly googled for a list of all countries with codes, and found this .sql script
https://github.com/Svish/iso-3166-country-codes/tree/master

Thank you for your help

1 Like

Hi,

You can find the app’s static ids here:

1 Like

When I did a little additional searching after responding to your question, I did find a random PHP script on GitHub, that supposedly finds the code associated with country names. But I think it’s only run from the CLI, so wouldn’t really help.

1 Like

If anyone wants to get the countries through the API, there is the /statics endpoint:

https://api-docs.invoicing.co/#get-/api/v1/statics

Thanks @nlantonsch

After a little research through the php SDK

This gets a list of all countries data, if this is of use to others. I was using a 3rd party .sql list to do this, but i feel it better to use the InvoiceNinja list (now i had time to work out how to get this), just in case there are any differences, the invoiceNinja list should be 100% reliable

require_once DIR . ‘/vendor/autoload.php’;

use InvoiceNinja\Sdk\InvoiceNinja;

$ninja = new InvoiceNinja(YOUR_TOKEN);
$ninja->setUrl(YOUR_URL); // if self hosted

$countries = $ninja->statics->countries();

print_r($countries); // will give you a list of all countries and codes

1 Like