I have been thinking of hanging something outside my window. It occurred to me though that there are building codes. I am in a private home of my own but wondered to what extent building codes apply.
Nothing to do with building codes, unless you are hanging an addition to your house out the window.
Your own (single-family) home on your own lot (piece of land) - depends what you have (or don't) for a home-owner's association, or if your house is subject to some sort of restrictive covenant such as a historic preservation district.
A home that is part of a multiple-dwelling unit where you own the space in the building, but not the land - more likely to have some other rules and regulations impacting what you can do from your windows, in the interest of protecting other people.
Note that on your own property you still have an interest in protecting other people, but it comes mostly from the fact that they can sue you, so if you plan to hang something very dubious safety-wise out the window, your insurance company may decide that you are a bad risk and cancel your coverage or raise your rates.