Integrate FileMaker & WeatherStack using APIs – desegregate double entry.

Getting started with Integrate FileMaker API in 5 Easy Steps.

Like you, I wanted to learn how to use FileMaker’s APIs, so I started researching free APIs. I had a very general idea of how an API worked and decided to make a simple API with the available information I already knew about accessing the API data and then parsing the data into a relevant field. So I started by researching weather APIs and found WeatherStack. WeatherStack has three available plans. The free account is limited but will allow you 1000 calls for no cost. This is a great way to get started learning how to make an API call.

Step 1. Go to Website and Create a Free Account

First, go to https://weatherstack.com and sign up for and API it is Free, you can do this by pressing the “Start Using The API” button located on the main screen.

Once you are registered and logged in to your dashboard, you will receive an API key. This key is used to identify your current plan subscription and usage.

Now you are ready to get started. In your FileMaker database create the following fields.

Step 2. Use an Existing or new FileMaker Database and Create Your Fields

API – Will be used to hold your personal API code generated from weatherstack.com

City – This will contain the city and state you wish to find the weather for.

Master URL – Copy the following into your master URL path.

http://api.weatherstack.com/current?access_key=<API>&query=<City>

URL Calc – Calculation field which will Substitute your data, 

Substitute ( Master URL ; 

[“<City>” ; City];

[“<API>” ; API]

 )

Date = Date

Description  = Text

Temperature  =  Number

FeelsLike = Number

Humdity  =  Number

Pressure  =  Number

Precip = Number

Visibity  = Number

Wind Speed  = Number

Wind Direction  = Text

Wind Degree  = Number

Icon Path  = Text

Icon Container = Container

JSON = Text

Step 3. Create Your Script

Now create a script called “SET JSON”, when the script is performed FileMaker query the Weatherstack API for real-time weather data in a location of your choice.

Your results can be found in your JSON field and will look something like this.

{“request”:{“type”:”City”,”query”:”New York, United States of America”,”language”:”en”,”unit”:”m”},”location”:{“name”:”New York”,”country”:”United States of America”,”region”:”New York”,”lat”:”40.714″,”lon”:”-74.006″,”timezone_id”:”America\/New_York”,”localtime”:”2020-06-15 16:52″,”localtime_epoch”:1592239920,”utc_offset”:”-4.0″},”current”:{“observation_time”:”08:52 PM”,”temperature”:23,”weather_code”:113,”weather_icons”:[“https:\/\/assets.weatherstack.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png”],”weather_descriptions”:[“Sunny”],”wind_speed”:0,”wind_degree”:83,”wind_dir”:”E”,”pressure”:1030,”precip”:0,”humidity”:36,”cloudcover”:0,”feelslike”:24,”uv_index”:8,”visibility”:16,”is_day”:”yes”}}

Now that you have your API data results you can use, FileMaker’s JSONGetElement function to parse your data results.

If you are not familiar with using this function, don’t worry it is not as scary as you might think. Use your data viewer to assist you. Section in the JSON will open and look something like this {“request”: and will close looking like this “}

In this example there are two sections. Request and Current

If you enter JSONGetElement ( Settings::JSON ; “request” ). You will notice FileMaker returns the following results.

{“language”:”en”,”query”:”Mission Viejo, United States of America”,”type”:”City”,”unit”:”m”}

You can then narrow your results by entering in a second element this is done by adding a dot/period between values.

JSONGetElement ( Settings::JSON ; “request.language” )

Which as you can see returns the following results. “en”

To query the second section your request will look like this.

JSONGetElement ( Settings::JSON ; “current” )

{“cloudcover”:25,”feelslike”:25,”humidity”:59,”is_day”:”yes”,”observation_time”:”07:46 PM”,”precip”:0,”pressure”:1015,”temperature”:22,”uv_index”:10,”visibility”:16,”weather_code”:116,”weather_descriptions”:[“Partly cloudy”],”weather_icons”:[“https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png”],”wind_degree”:210,”wind_dir”:”SSW”,”wind_speed”:20}

To narrow your results add a section name.

JSONGetElement ( Settings::JSON ; “current.humidity” )

In this example the data only goes down one category from current it is possible the data drills down further, using the a period between values will allow you to drill down to the next section as needed.

Additionally, if this was a 5 day forecast, you might find that the JSON repeats for each day of the week. To get the first repetition you data may look something like this JSONGetElement ( Settings::JSON ; “current[0].humidity” ) zero always will indicate the first repetition.

Now go to your field definition and define each of your field as follows, you will find that some of the data will parse out but will include extra characters you may not want. 

This was true for some field, like the icons path.  Which will be used to pull the weather icon. I also found this to be true for the temperature. The JSON gave me Celsius results when I wanted Fahrenheit. 

It is possible I could have made this change in my API call to correct this, but instead I created a custom function to convert Celsius to Fahrenheit and created an additional field call “temp letter” this field can be used as a setting to flip between Celsius to Fahrenheit and is also used for display purpose to let the user know the weather format used.

Step 4. Add Custom Functions define Fields

From my experience, I have learned that you may need help every once in a while converting your data. An excellent example of this was when I did a Hubspot API, and the data comes over in a UNIX style format that is was not easily converted. The good news is there are plenty of free custom functions to help you out. In this example, I used a custom function called CelsToFahr to convert my data from Celsius to Fahrenheit.

((degreesCelsius/5)*9)+ 32

DEFINE YOUR FIELDS

Date = Let ( $Date = Left ( 

JSONGetElement ( Settings::JSON ; “location.localtime”  ) ; 10 );

Date ( Middle ( $Date ; 6 ; 2 );Right ( $Date ; 2 )

Description  = Substitute ( JSONGetElement (Settings::JSON ; “current.weather_descriptions” ) ;

[ “\”” ; “” ];[“[“;””];[“]”;””])

Humidity =  JSONGetElement (Settings::JSON ; “current.humidity” )

Precip = JSONGetElement (Settings::JSON ; “current.precip” )

Pressure  =  JSONGetElement (Settings::JSON ; “current.pressure” )

Visibity  = JSONGetElement (Settings::JSON ; “current.visibility” )

Wind Speed  = JSONGetElement (Settings::JSON ; “current.wind_speed” )

Wind Direction  = JSONGetElement (Settings::JSON ; “current.wind_dir” )

Wind Degree  = JSONGetElement (Settings::JSON ; “current.wind_degree” )

Icon Path  = Substitute ( JSONGetElement (Settings::JSON ; “current.weather_icons” ); 

[ “\”” ; “” ];[“[“;””];[“]”;””])

Substitute ( JSONGetElement (Settings::JSON ; “current.weather_icons” ); 

[ “\”” ; “” ]; [“[“;””]; [“]”;””])

Temperature  =  If(

temp_letter=”C”;JSONGetElement (Settings::JSON ; “current.temperature” );

CelsToFahr ( JSONGetElement (Settings::JSON ; “current.temperature” ) ))

FeelsLike = If(

temp_letter=”C”;JSONGetElement (Settings::JSON ; “current.feelslike” );

CelsToFahr ( JSONGetElement (Settings::JSON ; “current.feelslike” ) )) Number

Step 5. Test and Run your Script

Now that everything is in place, be sure to enter the city you would like to get the weather for. Then run your SET JSON script and it will call and parse your data.

ADDITIONAL INFORMATION

From the WeatherStack webpage, you can view the API documentation https://weatherstack.com/documentation, this documentation for this demo, however, if you would like to further your skills. You may find this page very insightful.

Good Luck!!

Kitty Kane

Database Interface – choosing a color theme for your database

Finding a color scheme can make the world of difference when it comes to creating a database interface that is both eye-catching and functional.

Finding that perfect match can make any database more appealing and help provide visual clues to make content and use more effective. Below are some suggestions on how to choose an effective color scheme.

Color scheme selection, much like brand marketing is an important part of business industry and brand. To better understand what colors work well together you’ll need to revisit color theory history.

Remember the color wheel? Well, it all stems from that. Primary colors (red, yellow and blue) make-up all the goods. From there, you get secondary colors which are like the color wheel x 2. The third step is the tertiary colors, which is one more level of color division from mixing a primary and a secondary.

Now that we’ve refreshed our understanding of how colors are formed, we now need to know how to make them harmonize. To create color harmony you need to make them flow and feel like they belong together—much like the notes in a song, hence the harmony. You need to achieve the perfect balance of color to really make the database flow.

Too little color and your database come across as dull and too subdued. On the other hand, if colors are too extreme, and can become visually distracting and hard to maintain focus. Color harmony can be achieved by creating a perfect balance. Two of the most common formulas for harmony are to use analogous colors (colors that are side-by-side on the color wheel) and complementary (colors that are opposing each other on the color wheel).

So, how do you go about picking the colors for your database theme? Most likely you’ve already got an idea of colors from your companies logo or brand marketing. Most of the time your logo is only going to consist of 2 or 3 colors. If it’s got more than that contact us today because it’s probably looking like a hot mess and needs some attention.

When choosing a color scheme. Try to focus on the client’s industry and make sure the color scheme is in line with the company logo and maintaining the brand’s consistency as well as staying true to the industry’s feel.

The Adobe CC color pallet is a wonderful tool that allows you to select your color and then view built-in formulas that create concrete, pleasing visual pallets. This is an excellent reference tool. Like color picking on steroids. They’ve even got an app to allow you to select colors based on inspirations or photos.

Visit the Adobe Color Theme Library.

Woman-Owned and Operated FileMaker Pro Developer

How being a Woman FileMaker Pro Developer, is a business advantage.

As you might have learned, I started out as a Fine Arts major. Computers were new, I had only taken one computer class. But after getting my first real job as a paste-up artist for the PennySaver. I changed my major to a Graphic Artist. I worked on my first Mac in 1990, the computer department was all men.

Since then I have worked for many companies. I have worked under Women managers and Men managers. If you were to ask me which ones were better managers I would most likely tell you that I have worked for just as many good men managers as I have good woman managers and vice versa.

So what is my reasoning for pointing out I am a woman-owned and operated company? Well this month I attended the 2016 FileMaker DevCon, (a conference for FileMaker developers and companies using FileMaker Pro for their business.) Each year they have a Woman of FileMaker luncheon, which sadly I missed.

But I can tell you that as I was reading the program, I thought to myself why is there a luncheon for women?! Well first, I learned that Women of FileMaker makes up only 20% of all FileMaker Pro developers. I have never considered myself different, but I have been thinking for some time I am the best looking woman in the room. (Most likely because I am usually the only woman in the room).

But seriously, when I thought about it why are there so few women when some of the most important skills of being a FileMaker pro developer women excel in: Organization, Memory, Multitasking, Communication, Collaboration.

During my 2016 FileMaker DevCon I attended one Of Jonathan Stark Filemaker presentations, I landed there on accident only to learn it was one of the best things about this year’s developer conference for me personally. Jonathan spoke about business strategies and how to differentiate yourself in a pool of others who do exactly what you do.

His advice was to present yourself for what makes you different and although I struggled with the idea. I have decided I am different. I am a woman, and a FileMaker Pro developer.

Choosing a developer can be difficult, but being prepared and asking the right question before getting started can ease your stress and create a long-lasting prosperous relationship for both parties.
Looking to hire a Filemaker developer in Orange County, CA? Call today and we would be happy to discuss your needs for updating or creating the Filemaker solution best for your project.

Looking to Hire a FileMaker Developer? Call today: 949-689-8915
www.filemakerproexpert.com