openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
647 stars 374 forks source link

Add an API for country detection using GS1 Barcode prefixes #409

Open teolemon opened 8 years ago

teolemon commented 8 years ago

What

Why

How

Caveats

Part of

teolemon commented 8 years ago
teolemon commented 8 years ago
Prefix Country
000 - 019 GS1 US
020 - 029 Restricted circulation numbers within a geographic region (MO defined)
030 - 039 GS1 US
040 - 049 Restricted circulation numbers within a company
050 - 059 GS1 US reserved for future use
060 - 139 GS1 US
200 - 299 Restricted circulation numbers within a geographic region (MO defined)
300 - 379 GS1 France
380 GS1 Bulgaria
383 GS1 Slovenija
385 GS1 Croatia
387 GS1 BIH (Bosnia-Herzegovina)
389 GS1 Montenegro
400 - 440 GS1 Germany
450 - 459 & 490 - 499 GS1 Japan
460 - 469 GS1 Russia
470 GS1 Kyrgyzstan
471 GS1 Taiwan
474 GS1 Estonia
475 GS1 Latvia
476 GS1 Azerbaijan
477 GS1 Lithuania
478 GS1 Uzbekistan
479 GS1 Sri Lanka
480 GS1 Philippines
481 GS1 Belarus
482 GS1 Ukraine
483 GS1 Turkmenistan
484 GS1 Moldova
485 GS1 Armenia
486 GS1 Georgia
487 GS1 Kazakstan
488 GS1 Tajikistan
489 GS1 Hong Kong
500 - 509 GS1 UK
520 - 521 GS1 Association Greece
528 GS1 Lebanon
529 GS1 Cyprus
530 GS1 Albania
531 GS1 Macedonia
535 GS1 Malta
539 GS1 Ireland
540 - 549 GS1 Belgium & Luxembourg
560 GS1 Portugal
569 GS1 Iceland
570 - 579 GS1 Denmark
590 GS1 Poland
594 GS1 Romania
599 GS1 Hungary
600 - 601 GS1 South Africa
603 GS1 Ghana
604 GS1 Senegal
608 GS1 Bahrain
609 GS1 Mauritius
611 GS1 Morocco
613 GS1 Algeria
615 GS1 Nigeria
616 GS1 Kenya
618 GS1 Ivory Coast
619 GS1 Tunisia
620 GS1 Tanzania
621 GS1 Syria
622 GS1 Egypt
623 GS1 Brunei
624 GS1 Libya
625 GS1 Jordan
626 GS1 Iran
627 GS1 Kuwait
628 GS1 Saudi Arabia
629 GS1 Emirates
640 - 649 GS1 Finland
690 - 699 GS1 China
700 - 709 GS1 Norway
729 GS1 Israel
730 - 739 GS1 Sweden
740 GS1 Guatemala
741 GS1 El Salvador
742 GS1 Honduras
743 GS1 Nicaragua
744 GS1 Costa Rica
745 GS1 Panama
746 GS1 Republica Dominicana
750 GS1 Mexico
754 - 755 GS1 Canada
759 GS1 Venezuela
760 - 769 GS1 Schweiz, Suisse, Svizzera
770 - 771 GS1 Colombia
773 GS1 Uruguay
775 GS1 Peru
777 GS1 Bolivia
778 - 779 GS1 Argentina
780 GS1 Chile
784 GS1 Paraguay
786 GS1 Ecuador
789 - 790 GS1 Brasil
800 - 839 GS1 Italy
840 - 849 GS1 Spain
850 GS1 Cuba
858 GS1 Slovakia
859 GS1 Czech
860 GS1 Serbia
865 GS1 Mongolia
867 GS1 North Korea
868 - 869 GS1 Turkey
870 - 879 GS1 Netherlands
880 GS1 South Korea
884 GS1 Cambodia
885 GS1 Thailand
888 GS1 Singapore
890 GS1 India
893 GS1 Vietnam
896 GS1 Pakistan
899 GS1 Indonesia
900 - 919 GS1 Austria
930 - 939 GS1 Australia
940 - 949 GS1 New Zealand
950 GS1 Global Office
951 GS1 Global Office (EPCglobal)
955 GS1 Malaysia
958 GS1 Macau
960-969 Global Office (GTIN-8s)
977 Serial publications (ISSN)
978 - 979 Bookland (ISBN)
980 Refund receipts
981 - 984 GS1 coupon identification for common currency areas
99 GS1 coupon identification
Notes:
960 and 9610-9614 have been assigned to GS1 UK for GTIN-8 allocations.
Prefixes not listed above are reserved by GS1 Global Office for allocations in non-member countries and for future use.
TaciteOFF commented 8 years ago

I don't think it's a good idea to automatically add a country with that.

The code you're mentioning refers to the company headquarters.

There are products with spanish barcodes sold in France and not in Spain.

teolemon commented 8 years ago

This is not my intention. It just about having the ability to make guesses and let the user decide.

teolemon commented 6 years ago

{"country":"United States" , "barcode" : "000 – 019"},
{"country":"Canada" , "barcode" : "000 – 019"}, {"country":"United States drugs" , "barcode" : "030 – 039"},
{"country":"United States and Canada" , "barcode" : "060 – 099"},
{"country":"United States" , "barcode" : "100 – 139"},
{"country":"France and Monaco" , "barcode" : "300 – 379"},
{"country":"Bulgaria" , "barcode" : "380"},
{"country":"Slovenia" , "barcode" : "383"},
{"country":"Croatia" , "barcode" : "385"},
{"country":"Bosnia and Herzegovina" , "barcode" : "387"},
{"country":"Montenegro" , "barcode" : "389"},
{"country":"Kosovo" , "barcode" : "390"},
{"country":"Germany" , "barcode" : "400 – 440"},
{"country":"Japan" , "barcode" : "450 – 459"},
{"country":"Russia" , "barcode" : "460 – 469"},
{"country":"Kyrgyzstan" , "barcode" : "470"},
{"country":"Taiwan" , "barcode" : "471"},
{"country":"Estonia" , "barcode" : "474"},
{"country":"Latvia" , "barcode" : "475"},
{"country":"Azerbaijan" , "barcode" : "476"},
{"country":"Lithuania" , "barcode" : "477"},
{"country":"Uzbekistan" , "barcode" : "478"},
{"country":"Sri Lanka" , "barcode" : "479"},
{"country":"Philippines" , "barcode" : "480"},
{"country":"Belarus" , "barcode" : "481"},
{"country":"Ukraine" , "barcode" : "482"},
{"country":"Turkmenistan" , "barcode" : "483"},
{"country":"Moldova" , "barcode" : "484"},
{"country":"Armenia" , "barcode" : "485"},
{"country":"Georgia" , "barcode" : "486"},
{"country":"Kazakhstan" , "barcode" : "487"},
{"country":"Tajikistan" , "barcode" : "488"},
{"country":"Hong Kong" , "barcode" : "489"},
{"country":"Japan" , "barcode" : "490 – 499"},
{"country":"United Kingdom" , "barcode" : "500 – 509"},
{"country":"Greece" , "barcode" : "520 – 521"},
{"country":"Lebanon" , "barcode" : "528"},
{"country":"Cyprus" , "barcode" : "529"},
{"country":"Albania" , "barcode" : "530"},
{"country":"Macedonia" , "barcode" : "531"},
{"country":"Malta" , "barcode" : "535"},
{"country":"Republic of Ireland" , "barcode" : "539"},
{"country":"Belgium and Luxembourg" , "barcode" : "540 – 549"},
{"country":"Portugal" , "barcode" : "560"},
{"country":"Iceland" , "barcode" : "569"},
{"country":"Denmark" , "barcode" : "570 – 579"},
{"country":"Faroe Islands" , "barcode" : "570 – 579"},
{"country":"Greenland" , "barcode" : "570 – 579"},
{"country":"Poland" , "barcode" : "590"},
{"country":"Romania" , "barcode" : "594"},
{"country":"Hungary" , "barcode" : "599"},
{"country":"South Africa" , "barcode" : "600 – 601"},
{"country":"Ghana" , "barcode" : "603"},
{"country":"Senegal" , "barcode" : "604"},
{"country":"Bahrain" , "barcode" : "608"},
{"country":"Mauritius" , "barcode" : "609"},
{"country":"Morocco" , "barcode" : "611"},
{"country":"Algeria" , "barcode" : "613"},
{"country":"Nigeria" , "barcode" : "615"},
{"country":"Kenya" , "barcode" : "616"},
{"country":"Ivory Coast" , "barcode" : "618"},
{"country":"Tunisia" , "barcode" : "619"},
{"country":"Tanzania" , "barcode" : "620"},
{"country":"Syria" , "barcode" : "621"},
{"country":"Egypt" , "barcode" : "622"},
{"country":"Brunei" , "barcode" : "623"},
{"country":"Libya" , "barcode" : "624"},
{"country":"Jordan" , "barcode" : "625"},
{"country":"Iran" , "barcode" : "626"},
{"country":"Kuwait" , "barcode" : "627"},
{"country":"Saudi Arabia" , "barcode" : "628"},
{"country":"United Arab Emirates" , "barcode" : "629"},
{"country":"Finland" , "barcode" : "640 – 649"},
{"country":"China" , "barcode" : "690 – 699"},
{"country":"Norway" , "barcode" : "700 – 709"},
{"country":"Israel" , "barcode" : "729"},
{"country":"Sweden : EAN/GS1 Sweden" , "barcode" : "730 – 739"},
{"country":"Guatemala" , "barcode" : "740"},
{"country":"El Salvador" , "barcode" : "741"},
{"country":"Honduras" , "barcode" : "742"},
{"country":"Nicaragua" , "barcode" : "743"},
{"country":"Costa Rica" , "barcode" : "744"},
{"country":"Panama" , "barcode" : "745"},
{"country":"Dominican Republic" , "barcode" : "746"},
{"country":"Mexico" , "barcode" : "750"},
{"country":"Canada" , "barcode" : "754 – 755"},
{"country":"Venezuela" , "barcode" : "759"},
{"country":"Switzerland and Liechtenstein" , "barcode" : "760 – 769"},
{"country":"Colombia" , "barcode" : "770 – 771"},
{"country":"Uruguay" , "barcode" : "773"},
{"country":"Peru" , "barcode" : "775"},
{"country":"Bolivia" , "barcode" : "777"},
{"country":"Argentina" , "barcode" : "778 – 779"},
{"country":"Chile" , "barcode" : "780"},
{"country":"Paraguay" , "barcode" : "784"},
{"country":"Ecuador" , "barcode" : "786"},
{"country":"Brazil" , "barcode" : "789 – 790"},
{"country":"Italy, San Marino and Vatican City" , "barcode" : "800 – 839"},
{"country":"Spain and Andorra" , "barcode" : "840 – 849"},
{"country":"Cuba" , "barcode" : "850"},
{"country":"Slovakia" , "barcode" : "858"},
{"country":"Czech Republic" , "barcode" : "859"},
{"country":"Serbia" , "barcode" : "860"},
{"country":"Mongolia" , "barcode" : "865"},
{"country":"North Korea" , "barcode" : "867"},
{"country":"Turkey" , "barcode" : "868 – 869"},
{"country":"Netherlands" , "barcode" : "870 – 879"},
{"country":"South Korea" , "barcode" : "880"},
{"country":"Cambodia" , "barcode" : "884"},
{"country":"Thailand" , "barcode" : "885"},
{"country":"Singapore" , "barcode" : "888"},
{"country":"India" , "barcode" : "890"},
{"country":"Vietnam" , "barcode" : "893"},
{"country":"Pakistan" , "barcode" : "896"},
{"country":"Indonesia" , "barcode" : "899"},
{"country":"Austria" , "barcode" : "900 – 919"},
{"country":"Australia" , "barcode" : "930 – 939"},
{"country":"New Zealand" , "barcode" : "940 – 949"},
{"country":"Malaysia" , "barcode" : "955"},
{"country":"Macau" , "barcode" : "958"}

bredowmax commented 4 years ago

This might work not only for countries but also for brands. There are quite a few brands which use barcodes from specific ranges.

For example: K-Classic (Kaufland) 4300175xxxxxx 4335896xxxxxx 4337185xxxxxx

More on this https://openfoodfacts.slack.com/archives/C21803P5W/p1580500458003600

Data: https://docs.google.com/spreadsheets/d/1wPciFWMvn9K0rIMW17Tgq6IDkCtH11QgoTsSaQ31ghM/edit?usp=sharing

bredowmax commented 4 years ago

I agree that we shouldn't tag automatically based on this information (too many products use a different barcode range that doesn't adhere to the GS-1 specification) but it could be very well used for suggesting edits to country & brand for Hunger-Games